-
-
Notifications
You must be signed in to change notification settings - Fork 9.7k
Description
Q | A |
---|---|
Bug report? | no |
Feature request? | yes |
BC Break report? | yes |
RFC? | yes |
Symfony version | 3.4.4 |
As described in http://symfony.com/blog/new-in-symfony-2-7-twig-as-a-first-class-citizen#what-about-performance, there is a performance penalty when using templating sub-system.
ControllerTrait::render() tries to render with templating
first, but one can optimize controllers by overriding it in base controller like:
public function render($view, array $parameters = [], Response $response = null)
{
if (null === $response) {
$response = new Response();
}
$response->setContent($this->get('twig')->render($view, $parameters));
return $response;
}
The method ControllerTrait::render()
is considered final since version 3.4, so it cannot be overridden any more, and this optimization is no longer possible.
One possibility can be:
templating:
enabled: false
but that can cause issues with some third party code that rely on templating
service.
So basically what I am trying to accomplish is to keep this optimization possible for controllers.
One idea was to try twig
first in ControllerTrait::render(), but that would probably break in some cases.
So, is there a workaround I am not aware of, or is there something we can do to allow this kind of optimizations in future versions?