My profiler toolbar isn't showing up in symfony 4.3.1
It's very hard, if not impossible, to debug this for you remotely. The exact problem is tied to something specific in your local setup, and someone without access to your project would not have a chance to see exactly what is wrong.
Some general and specific troubleshooting advice for your situation:
1st. Reinstall the profiler pack
While unusual, the installation could be borked. Make sure your profiler package is alright.
First remove it (composer remove profiler
), and then install it again: composer require --dev profiler
).
2nd. Check the configuration
Use Symfony's console command to verify your configuration.
First for the built-in profiler:
$ bin/console debug:config framework profiler
Which should return something like this:
Current configuration for "framework.profiler"==============================================only_exceptions: falseenabled: truecollect: trueonly_master_requests: falsedsn: 'file:%kernel.cache_dir%/profiler'
And then for the profiler toolbar:
$ bin/console debug:config web_profiler
Which should return something like:
Current configuration for extension with alias "web_profiler"=============================================================web_profiler: toolbar: true intercept_redirects: false excluded_ajax_paths: '^/((index|app(_[\w]+)?)\.php/)?_wdt'
3rd. Check the container
Check how the Profiler service will be instantiated:
$ bin/console debug:container profiler --show-arguments
Expect something like this:
Information for Service "profiler"================================== Profiler. ---------------- ------------------------------------------------------------------------------------- Option Value ---------------- ------------------------------------------------------------------------------------- Service ID profiler Class Symfony\Component\HttpKernel\Profiler\Profiler Tags monolog.logger (channel: profiler) kernel.reset (method: reset) Calls add, add, add, add, add, add, add, add, add, add, add, add, add, add, add, add, add Public yes Synthetic no Lazy no Shared yes Abstract no Autowired no Autoconfigured no Arguments Service(profiler.storage) Service(monolog.logger.profiler) 1 ---------------- -------------------------------------------------------------------------------------
And then for the web_toolbar:
# bin/console debug:container web_profiler.debug_toolbar --show-arguments
For something like this:
Information for Service "web_profiler.debug_toolbar"==================================================== WebDebugToolbarListener injects the Web Debug Toolbar. ---------------- ------------------------------------------------------------------------ Option Value ---------------- ------------------------------------------------------------------------ Service ID web_profiler.debug_toolbar Class Symfony\Bundle\WebProfilerBundle\EventListener\WebDebugToolbarListener Tags kernel.event_subscriber container.hot_path Public no Synthetic no Lazy no Shared yes Abstract no Autowired no Autoconfigured no Arguments Service(twig) 2 Service(router.default) ^/((index|app(_[\w]+)?)\.php/)?_wdt Service(web_profiler.csp.handler) ---------------- ------------------------------------------------------------------------
(Note the 2
, which enables the toolbar).
4th. Check the event dispatcher.
The web debug toolbar is injected during the kernel.response
event. Check that the callback is appropriately hooked:
$ bin/console debug:event-dispatcher kernel.response
Which will return something like this:
Registered Listeners for "kernel.response" Event================================================ ------- -------------------------------------------------------------------------------------------- ---------- Order Callable Priority ------- -------------------------------------------------------------------------------------------- ---------- #1 ApiPlatform\Core\Hydra\EventListener\AddLinkHeaderListener::onKernelResponse() 0 #2 Symfony\Component\HttpKernel\EventListener\ResponseListener::onKernelResponse() 0 #3 Symfony\Component\HttpKernel\DataCollector\RequestDataCollector::onKernelResponse() 0 #4 Symfony\Component\WebLink\EventListener\AddLinkHeaderListener::onKernelResponse() 0 #5 Symfony\Component\Security\Http\RememberMe\ResponseListener::onKernelResponse() 0 #6 ApiPlatform\Core\HttpCache\EventListener\AddHeadersListener::onKernelResponse() -1 #7 Symfony\Component\HttpKernel\EventListener\ProfilerListener::onKernelResponse() -100 #8 Symfony\Bundle\WebProfilerBundle\EventListener\WebDebugToolbarListener::onKernelResponse() -128 #9 Symfony\Component\HttpKernel\EventListener\TestSessionListener::onKernelResponse() -128 #10 Symfony\Component\HttpKernel\EventListener\DisallowRobotsIndexingListener::onResponse() -255 #11 Symfony\Component\HttpKernel\EventListener\SessionListener::onKernelResponse() -1000 #12 Symfony\Component\HttpKernel\EventListener\StreamedResponseListener::onKernelResponse() -1024 ------- -------------------------------------------------------------------------------------------- ----------
Notice item #7
, which is the Profiler collector (which among other things will include the X-Debug-Token
header in the response, which will be later checked by the Web Debug Toolbar, which is item #8
in the above listing.
If any of the above checks fails
You'll have to focus on that specific part to find out why it is failing. Maybe some other bundle interfering? A problem with one of the configuration files?
Everything checks out
... but still not working? Well, that's weird. Make sure that your returned template has a </body>
tag, and that the returned response has text/html
content-type. But if all of the above checks out... it should work.
In a comment you say that framework.profiler.collect
is set to false when performing these checks.
Set it to true by changing config/packages/dev/web_profiler.yaml
like this:
framework: profiler: only_exceptions: false collect: true
I had a similar symptom in a new Symfony 5.1 app - debug toolbar not displaying on some pages even though the project was in debug mode. Turned out in this app I had intended to have the <body></body>
tags inside the twig template for each page, and not in the base template. But for a few pages (those that didn't display the debug toolbar), I had forgotten to include the <body></body>
tags in the page template, so the rendered HTML had no <body>
tag - hence debug toolbar will not display.