Hi!
I'm developing a multi-module app with phalcon. I have common elements and I want register only one time.
For example:
in /app/config/loader.php (charged in index.php):
$loader = new \Phalcon\Loader();
$loader->registerDirs(
array(
$config->application->componentsDir,
$config->application->pluginsDir,
)
)->register();
$loader->registerNamespaces(array(
'Phalcon' => '/vendor/phalcon/incubator/Library/Phalcon',
'Api\Controllers' => '/app/modules/api/controllers/'
));
$loader->register();
I need add 'Api\Controllers' => '/app/modules/api/controllers/' namespaces for all modules. I try to add in /app/config/loader.php, but the app not found the Controller.
The solution is add it in Module.php for all modules:
public function registerAutoloaders(\Phalcon\DiInterface $dependencyInjector = NULL)
{
$loader = new Loader();
$loader->registerNamespaces(array(
'User\Controllers' => __DIR__ . '/controllers/',
'User\Models' => __DIR__ . '/models/',
'Components' => __DIR__ . '/../../components/',
'Api\Controllers' => __DIR__ . '/../api/controllers/',
));
$loader->register();
}
There are any posibility to add all common Namespaces only in /app/config/loader.php ??