Solved thread

This post is marked as solved. If you think the information contained on this thread must be part of the official documentation, please contribute submitting a pull request to its repository.

Using Volt

HI there,

I have the following in my index.php file:

    //Setup the view component
    $di->set('view', function() use ($config) {
        $view = new \Phalcon\Mvc\View();
        $view->setViewsDir(__DIR__ . $config->application->viewsDir);
            '.volt' => 'volt'
        return $view;

    $di->set('volt', function($view, $di) {
        $volt = new \Phalcon\Mvc\View\Engine\Volt($view, $di);
            "compiledPath" => "../cache/volt/"
        return $volt;
    }, true);

Should I expect Phalcon to still process .phtml files in addition to .volt files or, should I expect Phalcon to process .volt files only?

Many thanks.


You have to add phtml files as well.

 * Setting up the view component
$di->set('view', function () use ($config) {
    $view = new View();                                                              
        '.volt' => function ($view, $di) use ($config) {
            $volt = new VoltEngine($view, $di);
                'compiledPath' => $config->application->cacheDir,
                'compiledSeparator' => '_',
                'compileAlways' => true
            return $volt;
        '.phtml' => 'Phalcon\Mvc\View\Engine\Php'

    return $view;
}, true);


Excellent. Thanks for this advice :)

Thanks a lot! In this comment I found an answer to my question - "how DISABLE volt in phalcon?" Also, you have to rename index.volt to index.phtml and replace volt's syntax to