We have moved our forum to GitHub Discussions. For questions about Phalcon v3/v4/v5 you can visit here and for Phalcon v6 here.

Error using devtools scaffold

Phalcon Devtools (2.0.0) PHP 5.5 Mysql 5.5.34 Apache 2.2.27 I installed with compose I created a project Created models with the phalcon models commands, it works. When I want to scaffold, the only answer I have is

Error: Parameter 'index' must be a string. Like that:
[~/public_html/xxxxxxxxxxxxxxx.com/etht]# phalcon scaffold Membre
Phalcon DevTools (2.0.0)                                           
  Error: Parameter 'index' must be a string  

If I create Controller first with the command phalcon controller, it goes a little bit furthe, it create 2 files:

[~/public_html/xxxxxxxxxxxxxxx.com/etht]# ../phalcon-devtools/phalcon controller Membre
Phalcon DevTools (2.0.0)    
  Success: Controller "Membre" was successfully created.  
[~/public_html/xxxxxxxxxxxxxxx.com/etht]# ../phalcon-devtools/phalcon scaffold Membre        
Phalcon DevTools (2.0.0)

/home/wdiqcca/public_html/xxxxxxxxxxxxxxx.com/etht/app/views/layouts/membre.phtml
/home/wdiqcca/public_html/xxxxxxxxxxxxxxx.com/etht/app/views/membre/index.phtml

  Error: Parameter 'index' must be a string  

After that I tried webtools, but I don't have the Config choice, and even if my config file is setup I'm getting:

Sorry, WebTools doesn't know where is the controllers directory. 
Please add to application section controllersDir param with valid path.
Sorry, WebTools doesn't know where is the models directory. 
Please add to application section modelsDir param with valid path.

My config file:

defined('APP_PATH') || define('APP_PATH', realpath('.'));

return new \Phalcon\Config(array(
    'database' => array(
        'adapter'     => 'Mysql',
        'host'        => 'localhost',
        'username'  => 'myusername',
        'password'  => 'mypassword',
        'dbname'    => 'mydb', 
        'charset'   => 'utf8'
    ),
    'application' => array(
        'controllersDir' => APP_PATH . '/app/controllers/',
        'modelsDir'      => APP_PATH . '/app/models/',
        'migrationsDir'  => APP_PATH . '/app/migrations/',
        'viewsDir'       => APP_PATH . '/app/views/',
        'pluginsDir'     => APP_PATH . '/app/plugins/',
        'libraryDir'     => APP_PATH . '/app/library/',
        'cacheDir'       => APP_PATH . '/app/cache/',
        'baseUri'        => '/etht/',
    )

Is there anyplace where I can see troubleshooting or is there someone who can help me?



43.9k
Accepted
answer

Hi,

I had troubles too, and I use:


    'application' => array(
        'controllersDir' => __DIR__ . '/../../app/controllers/',
        'modelsDir'      => __DIR__ . '/../../app/models/',
        'migrationsDir'  => __DIR__ . '/../../app/migrations/',
        'viewsDir'       => __DIR__ . '/../../app/views/',
        'pluginsDir'     => __DIR__ . '/../../app/plugins/',
        'libraryDir'     => __DIR__ . '/../../app/library/',
        'cacheDir'       => __DIR__ . '/../../app/cache/',
        'baseUri'        => '/phalcon/template1/',
    )


2.5k

Hi! First, thanks! It has not solved all my problems, but it solved a part of it. In fact, your answer inspired me to verify the path. And it was changing between the app and the web tools. I mean in webtools, it adds /etht/app in the path, so it didn't fond those directories. So I hardcoded the filepath: defined('APP_PATH') || define('APP_PATH', '/home/myuser/public_html/xxxxxxxx.com/etht') instead of defined('APP_PATH') || define('APP_PATH, /realpath('.')); and now the app (i Mean the welcom page) AND the webtools are working fine... Almost.

My scaffolding problem is still there. In webtools I'm getting a blank page, in terminal, I'm getting the same wonderful error: Parameter 'index'must be a string :(

Someone? :)



2.5k
edited May '15

Maybe I did something wrong in responding because my main problem is still there :(. I don't want my question to be marked as Solved :(

Phalcon Devtools (2.0.0) PHP 5.5 Mysql 5.5.34 Apache 2.2.27 I installed with compose I created a project Created models with the phalcon models commands, it works. When I want to scaffold, the only answer I have is

Error: Parameter 'index' must be a string. Like that: [~/public_html/xxxxxxxxxxxxxxx.com/etht]# phalcon scaffold Membre Phalcon DevTools (2.0.0)
Error: Parameter 'index' must be a string



If I create Controller first with the command phalcon controller, it goes a little bit furthe, it create 2 files:
[~/public_html/xxxxxxxxxxxxxxx.com/etht]# ../phalcon-devtools/phalcon controller Membre ```

Phalcon DevTools (2.0.0)    
  Success: Controller "Membre" was successfully created.
[~/public_html/xxxxxxxxxxxxxxx.com/etht]# ../phalcon-devtools/phalcon scaffold Membre
Phalcon DevTools (2.0.0)

/home/wdiqcca/public_html/xxxxxxxxxxxxxxx.com/etht/app/views/layouts/membre.phtml
/home/wdiqcca/public_html/xxxxxxxxxxxxxxx.com/etht/app/views/membre/index.phtml

  Error: Parameter 'index' must be a string

I used this (double dot) to solve my "don't know directories" problem, instead of adding dots in application array.

defined('APP_PATH') || define('APP_PATH', realpath('..'));

it is true. u just need change realpath parama from '.' to '..' in config.php

I made changes on lines 496,497, 708,710 in 'scripts\Phalcon\Builder\Scaffold.php' and It solved the issue for me.

    from:
        $this->options->attributes[0];

    To:
        $this->options->attributes->get('0');