15

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: [email protected]
    disable_delivery: false 
3
  • Don't you have any issues (alert opening in JS)? are you using the app_dev.php URL? don't you have a disabled conf in config_dev.yml with profiler.enabled: false?
    – Ninir
    Commented May 18, 2015 at 9:08
  • hi, can you check my config.yml and config_dev.yml if there are problems?
    – aiai
    Commented May 19, 2015 at 1:19
  • Ensure you are on the dev environment. I had the same problem and it turned out I was on the prod environment locally. Dump out {{ app.environment }} to confirm.
    – crmpicco
    Commented Sep 12, 2017 at 14:20

6 Answers 6

45

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 %}
9
  • I already change my config_dev.yml but still it does not show the profiler
    – aiai
    Commented May 19, 2015 at 2:02
  • Did you try to hard code true in the place of %debug_toolbar% to make it look like mine above?
    – BentCoder
    Commented May 19, 2015 at 7:08
  • yes ,, but still no luck ... instead I got an error like this "OutOfMemoryException: Error: Allowed memory size of 536870912 bytes exhausted (tried to allocate 2883686 bytes) in C:\xampp\htdocs\Editracker\vendor\symfony\symfony\src\Symfony\Component\HttpKernel\DataCollector\DataCollector.php line 35"
    – aiai
    Commented May 19, 2015 at 7:21
  • These is a simple solution for that particular eeror. Just google it.
    – BentCoder
    Commented May 19, 2015 at 7:24
  • yeah, already tried that by increasing the memory_limit but still it gives me this error.
    – aiai
    Commented May 19, 2015 at 7:27
7

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.

1
  • 2
    A shorter dirty solution return new Response("<body></body>"). This is nice when you have actions that run but don't have to output anything
    – Tomás Cot
    Commented May 19, 2017 at 13:04
1

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

1
  • In my case, it was idd a small Symfony icon in the right-bottom corner. After clicking on it, it was showing again. Tnx!
    – Ali Alwash
    Commented Jun 28, 2017 at 22:14
1

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

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

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).

Not the answer you're looking for? Browse other questions tagged or ask your own question.