Hi folks !
I'm new to Phalcon and I'm stuck with my router. It does give me the action and controller name, but the dispatcher doesn't link the controller and the action (always the default route).
I don't really know why ;(
Please help me.
my dispatcher:
$di->set(
'dispatcher',
function () use ($di) {
$eventsManager = new EventsManager;
/**
* Handle access control list using SecurityPlugin
*/
$eventsManager->attach('dispatch:beforeDispatch', new Security);
$eventsManager->attach("dispatch:beforeException", function($event, $dispatcher, $exception) {
//Handle 404 exceptions
if ($exception instanceof \Phalcon\Mvc\Dispatcher\Exception) {
$dispatcher->forward(array(
'controller' => 'errors',
'action' => 'show404'
));
return false;
}
//Handle other exceptions
$dispatcher->forward(array(
'controller' => 'errors',
'action' => 'show503'
));
return false;
});
$dispatcher = new Dispatcher;
$dispatcher->setEventsManager($eventsManager);
return $dispatcher;
}
);
and my router :
use Phalcon\Mvc\Router;
$router = new Router(false);
$router->add(
"/",
[
"controller" => "index",
"action" => "index",
]
);
$router->add(
"/users/login",
[
"controller" => "users",
"action" => "login",
]
);
$router->handle($_SERVER['REQUEST_URI']);
return $router;
Thanks a lot guys !