Solved thread

This post is marked as solved. If you think the information contained on this thread must be part of the official documentation, please contribute submitting a pull request to its repository.

Annotations router and modules?

For example, i have modules: core, blog.

Router initialization: ```php $router = new \Phalcon\Mvc\Router\Annotations(); $router->setDefaultModule('core');

// some routes

$router->addModuleResource('core', 'Index', '/');

And when i trying to reach http://mysite/ i have an exception: Uncaught exception 'ReflectionException' with message 'Class IndexController does not exist'

And bootstrap (Module.php) doesn't load, code doesn't executing:

php $loader->registerDirs(array( $this->getModuleDirectory() . '/controllers/', $this->getModuleDirectory() . '/models/', )); ```

I'am doing something wrong? The idea is to load dynamically routes from annotations, and not from file or by specified code.


The router doesn't load your modules, modules are loaded by Phalcon\Mvc\Application, so you need to register a global autoloader that allows the router to obtain the class reflection at least one time to read the annotations from the controllers.

Yeap, I knew it, Thanks!