How to render a templates with layouts using micro

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:

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();
        '.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);
            '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?


Thanks Thien,

Is there a way of specifying the main layout file in config and rendering a body template with ->render and {{ content() }} using micro?


You can refer sameple app