phalcon / phalcon-devtools

Phalcon Developer Tools
https://docs.phalcon.io/latest/en/devtools
Other
1.33k stars 629 forks source link

Fix #1506 config file locating issue #1507

Closed Ultimater closed 3 years ago

Ultimater commented 3 years ago

Hello!

In raising this pull request, I confirm the following (please check boxes):

Small description of change:

Fixes issue where

phalcon create-controller --name test

defaults to NULL as the directory where it searches for the config.php file in the wrong place, /, upon not finding it, the code falls back to a recursive directory search logic which then finds the public/webtools.config.php file and loads up the wrong config file causing an error:

PHP Fatal error: Uncaught Error: Call to a member function path() on int in /var/www/repos/phalcon-devtools/scripts/Phalcon/Builder/Controller.php:74 Stack trace:

0 /var/www/repos/phalcon-devtools/scripts/Phalcon/Commands/Builtin/Controller.php(74): Phalcon\Builder\Controller->build()

1 /var/www/repos/phalcon-devtools/scripts/Phalcon/Script.php(117): Phalcon\Commands\Builtin\Controller->run(Array)

2 /var/www/repos/phalcon-devtools/scripts/Phalcon/Script.php(151): Phalcon\Script->dispatch(Object(Phalcon\Commands\Builtin\Controller))

3 /var/www/repos/phalcon-devtools/phalcon(76): Phalcon\Script->run()

4 {main}

thrown in /var/www/repos/phalcon-devtools/scripts/Phalcon/Builder/Controller.php on line 74

This can be worked around with:

phalcon create-controller --name test --directory .

but the code should not error when not specifying a directory.

Thanks