Description
In a project, we decided to disable templating (in prod env).
We don't need it in production because we are just generating xml. We send the response at the end of the controller (return $response->setContent($xml);
).
That's why we defined that in config.yml
:
framework:
# ....
templating: false
We started the project with Symfony 2.8 and recently jumped to 3.1. And that's when the problem came out: we can't clear the cache anymore in prod env because the templating now require to have at least one engine defined. Which seems to be like that for years.
But one commit, in the 3.1 branch, breaks the ability to disable templating: 39723c5
This commit remove canBeEnabled
and use canBeUnset
instead.
As far as I understand, it means the templating can be disabled and we don't have to worry about it. But the configuration of FrameworkBundle define the engines
as required (->isRequired()
). This means we can't disable templating because a child is required.
With Symfony 3.0.x ✅ :
[12:30:55](master *%=){0}jeremy@j0k:~/late$ composer up
- Updating symfony/symfony (v3.1.0 => v3.0.7)
Checking out 272ab3327c3d311aaa9f634730162ea00e9d9e93
[12:31:19](master *%=){0}jeremy@j0k:~/late$ php bin/console cache:clear --env=prod
// Clearing the cache for the prod environment with debug false
[OK] Cache for the "prod" environment (debug=false) was successfully cleared.
With Symfony >= 3.1.x ❌ :
[12:31:22](master *%=){0}jeremy@j0k:~/late$ composer up
- Updating symfony/symfony (v3.0.7 => v3.1.0)
Checking out e71d4713c506686e6cf027af44c97ee5d94c7db4
[12:35:04](master *%=){0}jeremy@j0k:~/late$ php bin/console cache:clear --env=prod
// Clearing the cache for the prod environment with debug false
[Symfony\Component\Config\Definition\Exception\InvalidConfigurationException]
The child node "engines" at path "framework.templating" must be configured.
I know we can define the engine to use php if we don't want to load and enable Twig but we don't want to load classes related to php templating either.
So what can be the solution to disable templating?
- should we re-use
->canBeUnset()
under templating configuration? - should we remove the requirement for
engines
node?
PS: it's the same for router, because it is also ->canBeEnabled()
but got a required child (resource
).