Hello everyone!
I have a REST API app that I'm adding a number of basic html pages to.
I have the following services.php:
<?PHP
use Phalcon\Mvc\View\Simple as View;
use Phalcon\Mvc\Url as UrlResolver;
use Phalcon\DI\FactoryDefault;
use Phalcon\Db\Adapter\Pdo\Mysql as DbAdapter;
$di = new FactoryDefault();
/**
* Sets the view component
*/
$di['view'] = function () use ($config) {
$view = new View();
$view->setViewsDir($config->application->viewsDir);
$view->registerEngines([
'.volt' => 'volt'
]);
return $view;
};
// Register Volt as a service
$di['volt'] = function($view, $di) use ($config)
{
$volt = new Phalcon\Mvc\View\Engine\Volt($view, $di);
$volt->setOptions(
array(
'compiledPath' => $config->volt->path,
'compiledExtension' => $config->volt->extension,
'compiledSeparator' => $config->volt->separator,
//'stat' => (bool) $config->volt->stat,
)
);
return $volt;
};
I am trying to render the following:
$app->get('/', function () use ($app)
{
// I'd like to render <viewDir>/index/dashboard.volt as
// the content inside <viewDir>/layouts/index.volt here
echo $app['view']->render('index');
});
How do you do that in micro?