简体   繁体   中英

Web Profiler not showing up in dev

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 could be the problem?

config.yml

imports:
    - { resource: parameters.yml }
    - { resource: security.yml }

framework:
    #esi:             ~
    #translator:      { fallback: "%locale%" }
    translator: ~
    secret:          "%secret%"
    router:
        resource: "%kernel.root_dir%/config/routing.yml"
        strict_requirements: ~
    form:            ~
    csrf_protection: ~
    validation:      { enable_annotations: true }
    templating:
        engines: ['twig']
        #assets_version: SomeVersionScheme
    default_locale:  "%locale%"
    trusted_hosts:   ~
    trusted_proxies: ~
    session:
        # handler_id set to null will use default session handler from php.ini
        handler_id:  ~
    fragments:       ~
    http_method_override: true

# Twig Configuration
twig:
    debug:            "%kernel.debug%"
    strict_variables: "%kernel.debug%"

# Assetic Configuration
assetic:
    debug:          "%kernel.debug%"
    use_controller: false
    bundles:        ['MatrixEdiBundle', 'FOSUserBundle']
    #java: /usr/bin/java
    filters:
        cssrewrite: ~
        #closure:
        #    jar: "%kernel.root_dir%/Resources/java/compiler.jar"
        #yui_css:
        #    jar: "%kernel.root_dir%/Resources/java/yuicompressor-2.4.7.jar"

# Doctrine Configuration
doctrine:
    dbal:
        driver:   "%database_driver%"
        host:     "%database_host%"
        port:     "%database_port%"
        dbname:   "%database_name%"
        user:     "%database_user%"
        password: "%database_password%"
        charset:  UTF8
        # if using pdo_sqlite as your database driver, add the path in parameters.yml
        # e.g. database_path: "%kernel.root_dir%/data/data.db3"
        # path:     "%database_path%"

    orm:
        auto_generate_proxy_classes: "%kernel.debug%"
        auto_mapping: true

# Swiftmailer Configuration
swiftmailer:
    transport: "%mailer_transport%"
    host:      "%mailer_host%"
    username:  "%mailer_user%"
    password:  "%mailer_password%"
    spool:     { type: memory }
fos_user:
    db_driver: orm # other valid values are 'mongodb', 'couchdb' and 'propel'
    firewall_name: main
    user_class: Matrix\MatrixUserBundle\Entity\User

config_dev.yml

imports:
    - { resource: config.yml }

framework:
    router:
        resource: "%kernel.root_dir%/config/routing_dev.yml"
        strict_requirements: true
    profiler: { only_exceptions: false }

web_profiler:
    toolbar: %debug_toolbar%
    intercept_redirects: %debug_redirects%

monolog:
    handlers:
        main:
            type:   stream
            path:   "%kernel.logs_dir%/%kernel.environment%.log"
            level:  debug
        console:
            type:   console
            bubble: false
        # uncomment to get logging in your browser
        # you may have to allow bigger header sizes in your Web server configuration
        #firephp:
        #    type:   firephp
        #    level:  info
        #chromephp:
        #    type:   chromephp
        #    level:  info

assetic:
    use_controller: %use_assetic_controller%

swiftmailer:
    #delivery_address: me@example.com
    disable_delivery: false 

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 (eg 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.

I had the same issue and tried all of the above to no avail. I switched windows in the browser to another application (with the wdt) and then switched back and all of a sudden it appeared (I had tried hard reload, etc, etc).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM