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

Compiled template name

Hi!

Is it normal, that if to use custom dir for compiled templates, the name of template includes full path from root? i.e. D%%%%Projects%%.......index.volt.compiled? Looks ugly :(

p.s. Phalcon 1.1, PHP 5.4 on Windows



98.9k

Yes, Volt gets the realpath of the template allowing to share the same compiled templates across several applications. In 1.2.0, you can implement your own compilation path strategy:

$volt->setOptions([
    'compiledPath' => function($templatePath) {
             // Just append the .php extension to the template path
             return $templatePath . '.php';
         }
]);

Or, you can implement any strategy you want, this recursively creates the same structure in another directory:

$volt->setOptions([
    'compiledPath' => function($templatePath) {
        $dirName = dirname($templatePath);
        if (!is_dir(CACHE_DIR . $dirName)) {
            mkdir(CACHE_DIR . $dirName);
        }
        return CACHE_DIR . $dirName;
    }
]);

Ok, thank you. Will wait 1.2 )