I
I
Ivan2014-08-15 18:31:35
symfony
Ivan, 2014-08-15 18:31:35

How to compress html in Symfony2 output?

I want to run the output through the following code:

$responce = ...;
$responce = str_replace(array("\n", "\r", "\t"), ' ', $responce);
$responce = preg_replace('/ {2,}/', ' ', $responce);
...

Found only 1 question on SO, but I don't quite understand the answer.
stackoverflow.com/questions/6669112/how-to-compres...
Where to override the FilterResponseEvent->onKernelResponse() method?
Or is it better to do such things with a filter for twig and run the base.html.twig template through it?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
N
Nikita Gusakov, 2014-08-16
@0neS

spaceless?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question