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?



12.9k

and if I dont have namespaces?



847

you could use glob to itterate file recursively



12.9k

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.