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

beforeCompile() or afterCompile()

Are there any events like that available? Couldn't find any info about that possibility in the documentation.

I am asking because I would like to remove all new lines from compiled template, obviously I wand to write readable .volt template but when it is compiled into php code and stored I want all new lines removed.

There is event in view that allows to modify the contents before it is rendered but that means the function would be running every time a page is accessed which is not needed in my case.

Any ideas how this could be done appreciated.



8.1k
$di->set('view', function() {

// Create Event Manager
        $eventsManager = new \Phalcon\Events\Manager();

// Create listener for "view" type
            $eventsManager->attach("view:afterRenderView", ...

Documentation requires full reading :)



2.0k
Accepted
answer

I am aware of that (and even mentioned it in my post) but that method doesn't allow to modify the compiled view content, only to modify the content before it is rendered (sent to browser)

I want my view file to be saved minified already and not minify it before every request.



8.1k

You can use any cache for this.