Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Symfony 2 debug toolbar not showing

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.

like image 993
The50 Avatar asked Mar 07 '17 14:03

The50


3 Answers

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.

like image 194
proPhet Avatar answered Nov 15 '22 03:11

proPhet


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.

like image 38
BehradKhodayar Avatar answered Nov 15 '22 02:11

BehradKhodayar


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.

like image 32
Francois Avatar answered Nov 15 '22 03:11

Francois