I'm very new to PhalconPHP but already like it :-) I have a question if any one could help.
This is the router I'm using in my index.php right now and it works.
$di = new Phalcon\DI\FactoryDefault();
$di['router'] = function() {
$router = new Phalcon\Mvc\Router(false);
switch ($_SERVER['HTTP_HOST']) {
case 'api.domain.com':
$router->add('/', 'api::index');
$router->add('/one', 'api::one');
$router->add('/two', 'api::two');
break;
default:
$router->add('/', 'index::index');
break;
} #switch
$router->notFound(array(
'controller' => 'index',
'action' => 'error'
));
return $router;
}; #router
But I would like to load this from /app/config/routes.php dynamicly or routes.json file. Something like this or similar.
$routes = array(
"api.domain.com" => array(
"/" => array('api' => 'index'),
"/api1" => array('api' => 'one'),
"/api2" => array('api' => 'two'),
),
"domain.com" => array(
"/" => array('index' => 'index'),
),
);
Also, is there a shorter way to make "notFound" ?
$router->notFound(array(
'controller' => 'index',
'action' => 'error'
));
to something like:
$router->notFound('index::error');
Thanks for any help :-)