Start loader:
$loader = new \Phalcon\Loader();
$loader->registerNamespaces(
array(
'Pl\Controllers' => $config->application->controllersDir,
)
)->register();
Set dispatcher w/namespaces:
$di->set('dispatcher', function() {
$dispatcher = new Phalcon\Mvc\Dispatcher();
$dispatcher->setDefaultNamespace('Pl\Controllers');
return $dispatcher;
});
Define controller:
<?
namespace Pl\Controllers;
/**
* @RoutePrefix("/page")
*/
class PageController extends \Phalcon\Mvc\Controller {
/**
* @Get("/index", name="pages-index")
*/
public function indexAction() {
}
Trying to get routes definitions from controller:
$di->set('router', function() {
$router = new \Phalcon\Mvc\Router\Annotations();
$router->addResource('Pl\Controllers\Page', '/page');
// dump routes
foreach ($router->getRoutes() as $r) {
echo $r->getName().'<br />';
}
Nothing outputs, and no routes added, no errors, router works as default /:contoller/:action
Please help :)