Twig error after Symfony 2.7 Update: "Extension" native_profiler "not included
After A Symfony
Update,composer.json
- "symfony / symfony": "2.4. *",
- "symfony / symfony": "2.7. *",
I am getting an error while running tests phpunit
. In env dev
and prod
everything works fine.
log output:
request.CRITICAL: Uncaught PHP Exception Twig_Error_Runtime: "The native_profiler" extension is not enabled in "@WebProfiler/Profiler/toolbar_js.html.twig"
source to share
The twig native profile extension is automatically enabled if debug mode is enabled and disabled if debug mode is disabled in Symfony 2.7. So if you warm up the cache with debug mode on a branch, the templates show up with the profiler enabled. But if the test is debugged (for example, using Chris Wallsmith's solution), the extension is disabled in the tests (but still enabled in the preprocessed templates) that cause the error. Clear the cache with debug mode disabled before running tests.
application / console cache: clear --env = test --no-debug
The cache will be cleared and warmed up without a profiler.
source to share
I had the same problem today but slightly different. In the end, I found out that TwigProfiler is automatically enabled in debug mode. In KernelTestCase.php I found:
isset($options['debug']) ? $options['debug'] : true
So, in my test applications, I added the "debug" => false parameter and it worked again.
source to share
We had a similar error for our jenkins. Our CI job runs (1) PHPUnit tests than (2) functional tests with LiipFunctionalTestBundle and at the end (3) protractor tests.
The branch templates were compiled by functional tests (2) that set up the kernel in debug mode. However, Protractor tests run PHP server in test env, but not in debug mode. Therefore, the branch templates were incompatible. I solved the problem by deleting the cache between steps (2) and (3).
source to share
Try updating the version. This helped me from version 1.18 to 1.24 .
Using Symfony 2.7 with Sylius 0.13
More information: https://github.com/symfony/symfony/issues/15318 https://github.com/twigphp/Twig/pull/1824
source to share