@Ak-Army
Thanks, Ak-Army ;)
If somebody is interested, below is the code that is working for me (don't forget to create the notFound action in your index controller otherwise you will be getting cyclic error).
//Registering a dispatcher
$di->set('dispatcher', function () {
//Create/Get an EventManager
$eventsManager = new \Phalcon\Events\Manager();
//Attach a listener
$eventsManager->attach("dispatch", function ($event, $dispatcher, $exception) {
//controller or action doesn't exist
if ($event->getType() == 'beforeException') {
switch ($exception->getCode()) {
case \Phalcon\Dispatcher::EXCEPTION_HANDLER_NOT_FOUND:
case \Phalcon\Dispatcher::EXCEPTION_ACTION_NOT_FOUND:
$dispatcher->forward(array(
'controller' => 'index',
'action' => 'notFound'
));
return false;
}
}
});
$dispatcher = new \Phalcon\Mvc\Dispatcher();
//Set default namespace to backend module
$dispatcher->setDefaultNamespace("Vokuro\Controllers");
//Bind the EventsManager to the dispatcher
$dispatcher->setEventsManager($eventsManager);
return $dispatcher;
});