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

Autoloading subfolders too

its soo good to register directories for the autoloader:

$loader->registerDirs( array( APP_PATH . $config->application->controllersDir, APP_PATH . $config->application->pluginsDir, APP_PATH . $config->application->libraryDir, APP_PATH . $config->application->libraryDir.'fold1/fold2', APP_PATH . $config->application->modelsDir, APP_PATH . $config->application->formsDir, ) )->register();

my problem is I have to register all directories one by one. How to make it work so that search in subdirectories too?



28.1k

and if I dont have namespaces?



1.3k

you could use glob to itterate file recursively



28.1k

yea right, I just thought if there is a plugin or settings already

edited Sep '15

Look, this is a framework with great versatility, altough not unlimited options. If you have a directory tree that doesn't follow any PSR standards, don't expect to find a solution out-of-the-box. Phalcon\Loader is a utility class based on popular autoloader strategies in PHP projects.

I'd recommend refactoring your library to PSR-4 standards and use the namespace loading strategy.. Maintainability and performance are the main reasons to do so.