Autoloading subfolders too

its soo good to register directories for the autoloader:

$loader->registerDirs( array( APPPATH . $config->application->controllersDir, APPPATH . $config->application->pluginsDir, APPPATH . $config->application->libraryDir, APPPATH . $config->application->libraryDir.'fold1/fold2', APPPATH . $config->application->modelsDir, APPPATH . $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?



12.1k

and if I dont have namespaces?



828

you could use glob to itterate file recursively



12.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.