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"

      

+3


source to share


6 answers


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.

+6


source


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.

+1


source


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).

+1


source


Removing the cache after changing the debug mode seems to have solved my problem.

0


source


I had to use a switch --no-debug

also when generating javascript translation files withbazinga:js-translation:dump

For example, for example this command

../app/console bazinga:js-translation:dump -vvv --no-debug -e stage

      

0


source


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

0


source







All Articles