Codes are here.
I copied the router from the vokuro example, and added my own one. However, the first two don't even work.
routes.php
<?php
/*
- Define custom routes. File gets included in the router service definition.
*/
$router = new Phalcon\Mvc\Router();
$router->add("/confirm/{code}/{email}", array(
"controller" => "account",
"action" => "confirmEmail"
));
$router->add("/reset-password/{code}/{email}", array(
"controller" => "account",
"action" => "resetPassword"
));
$router->add("/manage/:object/:method/:params", array(
"controller" => "manage",
"action" => 1,
"method" => 2,
"params" => 3
));
return $router;
services.php
/
-
Dispatcher use a default namespace, and show 404 when not found
*/
$di->set(
'dispatcher',
function () use($di) {
$evManager = $di->getShared('eventsManager');
$evManager->attach(
"dispatch:beforeException",
function($event, $dispatcher, $exception)
{
switch ($exception->getCode()) {
case Dispatcher::EXCEPTION_HANDLER_NOT_FOUND:
case Dispatcher::EXCEPTION_ACTION_NOT_FOUND:
$dispatcher->forward(
array(
'controller' => 'error',
'action' => 'show404',
)
);
return false;
}
}
);
$dispatcher = new Dispatcher();
$dispatcher->setDefaultNamespace('Geohome_web\Controllers');
$dispatcher->setEventsManager($evManager);
return $dispatcher;
}
);
/*
- Loading routes from the routes.php file
*/
$di->set('router', function () {
return require DIR . '/routes.php';
});