Using Volt or PHP template engine the $views->getContent() returns always "". The action and the controller are the right ones, but the content of the index.volt (or index.phtml) is ignored. No exception is raised. The viewsDir is also correct and all the routes are mounted. When i try to get the main site, the response content is empty. I tried also using the application object, same result. I tried with Volt and PHP template engine, same result. The dir structure is:
pippo
boot
init.php
loader.php
services.php
controllers
routes (defined via groups)
views
index
index.phtml
index.volt
layout
partials
index.volt
index.phtml
Here is the init.php file:
try {
$config = new Phalcon\Config\Adapter\Ini(__DIR__.'/../config.ini');
// System bootstrap.
require __DIR__."/../boot/loader.php";
require __DIR__."/../boot/services.php";
// Request the services from the services container
$router = $di['router'];
$router->handle();
$dispatcher = $di['dispatcher'];
// Pass the processed router parameters to the dispatcher
$dispatcher->setControllerName($router->getControllerName());
$dispatcher->setActionName($router->getActionName());
$dispatcher->setParams($router->getParams());
// Dispatch the request
$dispatcher->dispatch();
$view = $di['view'];
// Start the view
$view->start();
// Renders the related views.
$view->render(
$dispatcher->getControllerName(),
$dispatcher->getActionName(),
$dispatcher->getParams()
);
//$view->setContent("<h1>this works instead</h1>");
// Finish the view
$view->finish();
$response = $di['response'];
// Pass the output of the view to the response
$response->setContent($view->getContent());
// Send the request headers
$response->sendHeaders();
// Print the response
echo $response->getContent();
}
catch (Phalcon\Exception $e) {
echo $e->getMessage();
}
I have also tried to pick the right view in the indexAction method of the IndexController class, but still it ignores the phtml or volt files.