Home » Php » php – How to add the Symfony Profiler to a Symfony 4.4 project?

php – How to add the Symfony Profiler to a Symfony 4.4 project?

Posted by: admin February 25, 2020 Leave a comment

Questions:

I am trying to add the profiler to a Symfony 4.4 project. Using symfony/profiler-pack adds the latest version, so version 5 and newer. It did not work. After some googling I found that I have to add Symfony\Bundle\WebProfilerBundle\WebProfilerBundle::class => ['all' => true] to config/bundles.php. (Yes, I know not to leave all there.)
So instead I explicitely used the version we use:

"symfony/stopwatch": "4.4.4",
"symfony/twig-bundle": "4.4.4",
"symfony/web-profiler-bundle": "4.4.4"

When I load the page I get the following error message in my browser:

Symfony \ Component \ DependencyInjection \ Exception \
ServiceNotFoundException
The service “web_profiler.controller.profiler” has a dependency on a non-existent service “twig”.

You can find the code and my change here: https://gitlab.com/foodsharing-dev/foodsharing/-/commit/fe6e6ebb3c2356e56a3d7f5757f0dcaf6d1a1557

Do you have any idea what I am doing wrong?

How to&Answers: