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

webtools not working when creating models, views and controllers

I'm having some problems while trying to get phalcon webtools working.

When using command line devtools I can create controllers and models without problems.

However, things aren't that easy with the webtools.

It correctly shows already created controllers and models:

And I can also edit them (https://i.imgur.com/orJweLl.png).

Apparently, Db connexion is ok, since webtools shows every table in the DB:

However, when trying to create a controller from the web interface, I got the next error:

"Please specify a controller directory"

Same when trying to create a Model from a database table :

"Database configuration cannot be loaded from your config file"

Or when trying to generate scaffold :

"Adapter was not found in the config. Please specify a config variable [database][adapter]"

  • My app/config/config.php content:

    return new \Phalcon\Config(array(
    'database' => array(
      'adapter'     => 'Mysql',
      'host'        => 'localhost',
      'username'    => 'phalcon',
      'password'    => 'phalcon',
      'dbname'      => 'phalcon',
      'charset'     => 'utf8',
    ),
    'application' => array(   
        'controllersDir' => __DIR__ . '/../../app/controllers/',
        'modelsDir'      => __DIR__ . '/../../app/models/',
        'viewsDir'       => __DIR__ . '/../../app/views/',
        'pluginsDir'     => __DIR__ . '/../../app/plugins/',
        'libraryDir'     => __DIR__ . '/../../app/library/',
        'cacheDir'       => __DIR__ . '/../../app/cache/',
        'baseUri'        => '/phalconTest/',
    )

    ));

  • My public/webtools.config.php content:

    define('PTOOLS_IP', '192.168.248.135');
    define('PTOOLSPATH', 'C:/phalcon-devtools');
  • My public/webtools.php:

    use Phalcon\Web\Tools;
    require 'webtools.config.php';
    require PTOOLSPATH . '/scripts/Phalcon/Web/Tools.php';
    
    Tools::main(PTOOLSPATH, PTOOLS_IP);

Im running Phalcon 1.3.4 - Windows x86 for PHP 5.4.0 (VC9)

Thanks in advance



2.1k

there is a bug with controller creation in dev tools.

i added a fix for it but it hasnt got pulled, needs someone to verify it =d

https://github.com/7thcubic/phalcon-devtools/tree/controller_directory



2.8k
edited Feb '15

Thanks, 7thcubic.

Would that also explain the problems I'm having while trying to create Models ? I'll try your fix and give you some feedback.



2.8k
edited Feb '15

I tried your fix and it didn't work for me.

Now I even have some php extra errors saying Constant PTOOLS_IP and PTOOLSPATH are already defined.

Some screenshots showing the error messages :

Any ideas ?

Thanks in advance

Edit:

I modified scripts/Phalcon/Builder/Component.php adding the next line:

$path = '../' . $path;

And now Controller generation works. But I still can't get Scaffolding and Model generation working. When trying to create a model I get 'Database configuration cannot be loaded from your config file' and it also show two messages telling that both PTOOLS_IP and PTOOLSPATH are already defined.

And for the scaffolding, now it shows two different new error messages: 'Builder doesn't knows where is the models directory' and 'Undefined index: modelsNamespace in C:\phalcon-devtools\scripts\Phalcon\Builder\Scaffold.php'. It also displays the PTOOLS_IP and PTOOLSPATH errors.



2.1k
edited Feb '15

you are using webtools??? man i didnt fix that lol

i think it has something to do with

https://github.com/7thcubic/phalcon-devtools/commit/c8c37de04a50fedc13f9abf6631901c87e835cb0

Also having this same issue.

Scaffold:

Notice: Constant PTOOLS_IP already defined in C:\Path-to\public\webtools.config.php on line 30 Notice: Constant PTOOLSPATH already defined in C:\Path-to\public\webtools.config.php on line 39

Adapter was not found in the config. Please specify a config variable [database][adapter]

Models:

Notice: Constant PTOOLS_IP already defined in C:\Path-to\public\webtools.config.php on line 30

Notice: Constant PTOOLSPATH already defined in C:\Path-to\webtools.config.php on line 39

Notice: Trying to get property of non-object in C:\Path-to\app\library\vendor\phalcon\devtools\scripts\Phalcon\Builder\AllModels.php on line 61

Notice: Trying to get property of non-object in C:\Path-to\app\library\vendor\phalcon\devtools\scripts\Phalcon\Builder\AllModels.php on line 61

Notice: Trying to get property of non-object in C:\Path-to\app\library\vendor\phalcon\devtools\scripts\Phalcon\Builder\AllModels.php on line 82

Notice: Trying to get property of non-object in C:\Path-to\app\library\vendor\phalcon\devtools\scripts\Phalcon\Builder\AllModels.php on line 82 Adapter is not supported