We are moving our forum in GitHub Discussions. For questions about Phalcon v3/v4 you can visit here and for Phalcon v5 here.

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.

Problem with Volt (again)

This morning I just get another problem with Volt. My code is:

$vista->registerEngines([
            '.volt' => 'Phalcon\Mvc\View\Engine\Volt',
            '.phtml' => function ($vista, $ID)
            {
                $volt       = new Volt($vista, $ID);
                $volt->setOptions([
                    'compileAlways' => true,
                    'compiledPath'  => '../vistas/compiladas/',
                    'compiledSeparator' => '_',
                    'compiledExtension' => '.compiled'
                ]);

                return $volt;
            }
        ]);

The problem is that compiledPath only works for one file (a Volt template), but not for the others: so I only get one file in his path, meanwhile I get all the others compiled in their homepaths.

I resolved this problem with a workaround time ago, but this morning just stop working (and that's why I'm trying to do this, more easy, way).



33.7k

Yeah, I used a function all the time before, and I would try again. But the function isn't reached now (I don't get the echo I put there).

And for your last phrase, don't worry, I separate templates from compiled templates and views from compiled views :D But I do not use a cache-static directory, I use just a directory (don't worry, this app is small to do caching).



33.7k

I wasn't mixing stuff: you use Volt as a service, while I use it as a closure. It worked all the time. Now I tried (yesterday and today) your piece of code, and yes it works; but Volt options aren't setted (the echo in there doesn't execute) , and the app doesn't work. No error is throwed. This is very very strange.



33.7k
Accepted
answer
edited Dec '14

The bootstrap file is in a whole try/catch block (as the tutorials show), but I don't get any exceptions. For security, I try/catched the specific part when setting the view and volt services but nothing. I think I will get back to the previous commit for the sake of god, because this is non-sense.

EDIT: Just as I said, non-sense. It works perfectly know.



33.7k

I getted similar not-bubbling 8I think) with ACL few days ago ( http://forum.phalcon.io/discussion/4070/silent-error-in-acl ). Let's hope that there is no more not-bubbling as you say.



33.7k

Ahhh my friend, I just know what happens: seems to be a bug (?). I thinked that $compiler = $volt->getCompiler() just before $volt->setOptions(..) wasn't dangerous. Indeed, it is, because it just skips the function.

I didn't write it in the post 'cause I didn't think that was the problem, but... So could you explain me why?