Web Profiler not showing up in dev

后端 未结 5 1019
旧巷少年郎
旧巷少年郎 2020-12-16 17:36

Im using Symfony2 (const version=\"2.5.10\") and using xampp with PHP version 5.5.19.

I got a problem that in my dev environment the profiler didn\'t show up.What co

相关标签:
5条回答
  • 2020-12-16 18:07

    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.

    0 讨论(0)
  • 2020-12-16 18:12

    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.

    0 讨论(0)
  • 2020-12-16 18:16

    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.

    0 讨论(0)
  • 2020-12-16 18:18

    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 %}
    
    0 讨论(0)
  • 2020-12-16 18:18

    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

    0 讨论(0)
提交回复
热议问题