Home » Php » php – How to enable profiler in symfony 4

php – How to enable profiler in symfony 4

Posted by: admin July 12, 2020 Leave a comment

Questions:

Solved:

I re-install it all over again and now it contains the web_profiler.yalm inside. Thanks to all.


The original question was:

I´m just starting to learn Symfony so I downloaded the free videos at KnpUniversity to get started. When I reached the video “Web Debug Toolbar & the Profiler!” I excecuted the next command:

> composer require profiler --dev

it installed OK.

Then, when I opened my app in the browser the “(…)slick black bar at the bottom…” didn’t show up.

I read somewhere that maybe is due to I haven’t installed symfony/debug but look at my composer.json:

"require-dev": {
        "sensiolabs/security-checker": "^4.1",
        "symfony/debug": "^4.0",
        "symfony/dotenv": "^4.0",
        "symfony/profiler-pack": "^1.0",
        "symfony/web-server-bundle": "^4.0"
    },

so I have it installed.

I excecuted the following command which give me the profiler configuration in my project:

> php bin/console debug:config web_profiler                   

Current configuration for extension with alias "web_profiler" 
============================================================= 

web_profiler:                                                 
    toolbar: false                                            
    intercept_redirects: false                                
    excluded_ajax_paths: '^/((index|app(_[\w]+)?)\.php/)?_wdt'

As you see above, the toolbar is set to false, How can I activate it? or How can I get the profiler bar showed up?

I’m using:

  • Composer version 1.6.5,
  • Symfony 4.1.1 and
  • PHP 7.2.7

Thanks in advance.

Solution:

I created a new project and it worked, it appears to be an error when composer was downloading the packages.

How to&Answers:

I’ve just installed new project and I can confirm that the profiler and toolbar are enabled by default. Configuration is found in config/packages/dev/web_profiler.yaml with the following configuration:

web_profiler:
    toolbar: true
    intercept_redirects: false

framework:
    profiler: { only_exceptions: false }

Answer:

Please be aware, that you have to attach web_profiler routes.

in:

config/routes/dev/web_profiler.yaml

web_profiler_wdt:
resource: '@WebProfilerBundle/Resources/config/routing/wdt.xml'
prefix: /_wdt

web_profiler_profiler:
resource: '@WebProfilerBundle/Resources/config/routing/profiler.xml'
prefix: /_profiler