We have moved our forum to GitHub Discussions. For questions about Phalcon v3/v4/v5 you can visit here and for Phalcon v6 here.

'phalcon create-project' creates project with volt by default - i don't want this

Hello,

I am new with phalcon and I have some problems:

Creating a new project: E:\xampp\htdocs\vendor\phalcon\devtools>phalcon.bat create-project ../test1 Phalcon DevTools (1.2.4) Success: Controller "index" was successfully created. Success: Project '../test1' was successfully created.

Result: E:\xampp\htdocs\vendor\phalcon\test1\app\views.volt

I do not want to use .volt template engine!

PS: devtools installed via composer. Renaming them to .phtml gets the template but it's not working properly = treats the content as a simple *.txt file.



17.8k
Accepted
answer
edited Mar '14

Go into '/app/config/services.php' and update this $di instance with the package you would like to use. Just pass in anything that your choice of template language might need and there ya go.

/**
 * Setting up the view component
 */
$di->set('view', function () use ($config) {

    $view = new View();

    $view->setViewsDir($config->application->viewsDir);

    $view->registerEngines(array(
        '.volt' => function ($view, $di) use ($config) {

            $volt = new VoltEngine($view, $di); 

            $volt->setOptions(array(
                'compiledPath' => $config->application->cacheDir,
                'compiledSeparator' => '_'
            )); 

            return $volt;
        },
        '.phtml' => 'Phalcon\Mvc\View\Engine\Php' 
    ));

    return $view;
}, true);

Also, check-out the docs for a small note on the subject... https://docs.phalcon.io/en/latest/reference/views.html#template-engines. This and the next three sections from that link show you how in a little more depth.