Symfony 2 debug toolbar not showing
Asked Answered
F

6

11

The Symfony debug toolbar doesn't show up.

I am running the site on app_dev.php environment. The config_dev.yml file contains the following lines.

web_profiler:
 toolbar: true
 intercept_redirects: false

app_dev/php doesn't have any IP restriction. It runs AppKernel with dev environment. Also, AppKernel contains the following line.

$bundles[] = new Symfony\Bundle\WebProfilerBundle\WebProfilerBundle();

The main problem could be the HTML markup, but it has both the opening and closing <body> tags. I even tried to remove all the HTML, and just leave it with few HTML tags, without luck.

Is there anything else I could try?
Maybe some files could be missing. How can I check it?

This is not a fresh Symfony installation.

Flambeau answered 7/3, 2017 at 14:5 Comment(4)
Just in case, If you execute the debug:router --env=dev command, can you see all _wdt and _profiler_* routes ?Monteith
I get debug:router: command not foundFlambeau
Maybe try with app/console router:debug --env=dev (it's old name). What's the exact version of your Symfony install ?Monteith
Oh this one works. Yes there is a _wdt and _profiler routes alongside with many other.Flambeau
L
20

Make sure you can tick all bullets in this checklist:

  • You are using the dev mode by accessing the page via app_dev.php (True for you)
  • The toolbar inserts itself in pages by looking for a terminating </body> tag on your generated page. If you don't have a </body> tag in your page the toolbar will not appear(as in the above answer). Example twig file as a reference:

    The line {% extends '::base.html.twig' %} will extend app/Resources/views/base.html.twig which injects default <body>...</body> into your custom twig files.

    {% extends '::base.html.twig' %}
    
    {% block body %}
      Hello!
    {% endblock %}
    
  • You have enabled the profiler in AppKernel.php

    public function registerBundles(){
      $bundles = ...
      if (in_array($this->getEnvironment(), array('dev', 'test'))) {
        $bundles[] = new Symfony\Bundle\WebProfilerBundle\WebProfilerBundle();
      ...
      }
    return $bundles;
    }
    
  • You have javascript enabled.

  • Thoroughly Check recently added bundles(specially custom ones). Because Cases like this can cause the problem.

Levirate answered 7/3, 2017 at 14:39 Comment(4)
Yes, double checked everything. Deleted the whole HTML, left only your example with base.html.twig. I am accessing the page using: project.test/project.dev/public_html/app_dev.phpFlambeau
@Flambeau Did you check the latest case I just added? Don't you have any new bundle installed?Levirate
Yes, there is a few custom bundles, but the problem is that the site is not working at all without a few of them. But I got the idea, need to run the site without any custom bundles at all first.Flambeau
Nice job @FlambeauLevirate
T
8

Double-check that your <body> tag has a closing </body> tag. In my experience, when the toolbar suddenly disappears it's because the closing body tag is missing due to malformed HTML, or because a controller is returning a Response object with just plain text content.

Tsaritsyn answered 7/3, 2017 at 14:26 Comment(0)
S
1

I had this issue with a large(ish) application where the toolbar wasn't being shown on memory heavy pages. Turns out that my php memory limit was being exhausted. I set the memory_limit in my php.ini file to something that would be adequate and that sorted it.

Stockholm answered 22/11, 2018 at 13:43 Comment(1)
Same here, it only happened on certain pages. I have twig files rendering lots of data. On app_dev.php It was too heavy and caused the toolbar error 'An error occurred while loading the web debug toolbar.' So solution was to raise the "memory_limit" in the fpm ini file (in my case /etc/php/7.3/fpm/php.ini)Hodosh
T
1

if you set the environment as dev it should display debug toolbar at the bottom

edit web/app.php as following;

$kernel = new AppKernel('dev', true);

Territory answered 12/2, 2019 at 18:46 Comment(0)
M
0

I recently got an old project in SF3.4 and in my case the debug toolbar didn't show up because of the following keys in config.yml file

framework:
    [...]
    profiler:
        collect: false

I commented on those 2 lines and it works again.

Murmansk answered 13/2, 2020 at 10:3 Comment(0)
M
0

Try to reinstall toolbar

composer remove profiler
composer require --dev profiler

Check the configuration

bin/console debug:config framework profiler
Midis answered 3/12, 2021 at 18:16 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.