We are moving our forum in GitHub Discussions. For questions about Phalcon v3/v4 you can visit here and for Phalcon v5 here.

WebTools not working with baseUri = /

I'm trying to use WebTools with my web app, with baseUri = /.

My app works fine at: domain.com/

And I can see WebTools by going to: domain.com/webtools.php.

The problem comes when I try to create a model using WebTools. It sees the database fine, but when it tries to write the model file it is trying to write to: /var/www/html/projectDir/../app/models/Widgets.php

Which resolves to a non-existent directory (one level up too far): /var/www/html/app/models/Widgets.php

Either of these would work: /var/www/html/projectDir/app/models/Widgets.php /var/www/html/projectDir/public/../app/models/Widgets.php

Here is my config, in /index.php:

$config = new \Phalcon\Config(array(
        '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'           => '/',

Any suggestions?



just put the absolute paths for your modelsDir, inside the config file, which within your case would be /var/www/html/projectDir/app/models. Also, please keep in mind that if you plan on using the webtools, the path to the models directory needs to be relative to webtools.php.

Hope this helps.