Реализация ResponseListener в вашем комплекте:
class ResponseListener
{
private $container;
public function __construct($container)
{
$this->container = $container;
}
public function onKernelResponse(FilterResponseEvent $event)
{
// Compress HTML on prod environment only
if($this->container->get('kernel')->getEnvironment() == 'prod')
$event->getResponse()->setContent(trim(preg_replace('/>\s+</', '><', $event->getResponse()->getContent())));
}
}
Затем объявите в services.yml:
services:
kernel.listener.response_listener:
class: AppBundle\Listener\ResponseListener
tags:
- { name: kernel.event_listener, event: kernel.response, method: onKernelResponse }
arguments: [@service_container]