Web Profiler not showing up in dev

江枫思渺然 提交于 2019-11-29 06:45:16

The profiler toolbar needs <body> ... </body>. I guess you don't have it in your twig file(s).

Profiler

# app/config/config_dev.yml
web_profiler:
    toolbar: true
    intercept_redirects: false

Example twig file.

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 %}

In case your action not returning html code (e.g json API) and you want to use profiler:

Quick and dirty solution:

return new Response("<html><body>Debug data</body></html>");

Even quicker and dirtier solution - returning non Response type in controller will raise exception with profiler enabled response:

return 1;

If your application is running by Symfony >=2.4 you can also use X-Debug-Token which contains debug token and X-Debug-Token-Link header which contains link to profiler page. If you want to use this method Chrome extension Symfony2 Profiler shortcut will increase your user experience.

have you enabled it in the config.yml or parameters.yml file? Are you in dev mode ? calling app_dev.php ?

also, it sometimes is minismised to a tidy square in the bottom right of the browser.

just some ideas that may help

Like the answer above has indicated, the web profiler doesn't appear in simple twig files that have a tag etc.

{% extends 'base.html.twig' %}

{% block body %}
    Hello {{name}}.
{% endblock %}

shows the web profiler, but something simple like:

 <body>
    Hello {{name}}.
 </body>

would work, but not show the web profiler.

I had the same issue.

The problem was in my routes definition. I has something like this:

load_home:
    path: /{page}
    defaults: {_controller: ExpatsBundle:Pages/Home:index, _format: html|json, page: 1}
    methods: GET
    requirements:
        page: \d+

So changing the _format: html|json to _format: html has solved the problem.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!