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.

'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.



15.5k
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... http://docs.phalconphp.com/en/latest/reference/views.html#template-engines. This and the next three sections from that link show you how in a little more depth.