Hello,
I am trying to extend the tutorial by adding new controllers and routes.
I am adding a rounter by using the Dependency Injection container like this:
$router = new Phalcon\Mvc\Router();
$router->add(
'/',
array(
'controller' => 'Index',
'action' => 'index',
)
);
$router->add(
"/request",
array(
'controller' => 'Request',
'action' => 'list',
'year' => 1
)
);
And then add it like this:
$di->set('router', $router);
I have created all the required dependencies (IndexController.php and RequestController.php with indexAction and listAction functions respectively, /views/index/index.phtml and /views/request/list.phtml).
Now, the behavior I see is this:
Router added:
- routes are used correctly, however I can only output from whithin controller action. Empty action = no output (no errors also), as if there were no views connected.
Router not added (comment out the set router line):
- views are rendered to the browser normally
Is there something I'm doing wrong? Do I need to set the views folders elsewhere aside from the way set in the tutorial? Eg:
$di->set('view', function(){
$view = new \Phalcon\Mvc\View();
$view->setViewsDir('../app/views/');
return $view;
});
Thanks!