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: me@example.com
    disable_delivery: false 
aiai
  • 1,129
  • 2
  • 11
  • 21
  • 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 May 18 '15 at 09:08
  • hi, can you check my config.yml and config_dev.yml if there are problems? – aiai May 19 '15 at 01: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 Sep 12 '17 at 14:20

6 Answers6

44

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 %}
BentCoder
  • 12,257
  • 22
  • 93
  • 165
  • I already change my config_dev.yml but still it does not show the profiler – aiai May 19 '15 at 02:02
  • Did you try to hard code `true` in the place of `%debug_toolbar%` to make it look like mine above? – BentCoder May 19 '15 at 07: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 May 19 '15 at 07:21
  • These is a simple solution for that particular eeror. Just google it. – BentCoder May 19 '15 at 07:24
  • yeah, already tried that by increasing the memory_limit but still it gives me this error. – aiai May 19 '15 at 07:27
  • its already working when i try to another page with no error , thanks , but problem now is the out of memory – aiai May 19 '15 at 07:38
  • No problem. Open a new question and give the link so that I can answer it as well cos it is irrelevant to this current context. – BentCoder May 19 '15 at 08:25
  • here it is : http://stackoverflow.com/questions/30229637/out-of-memory-error-in-symfony/30229866 – aiai May 19 '15 at 08:34
  • @BentCoder you are right. The body tag is required for the profiler to function. So, you either add body tag directly into your twig or extend base twig and overwrite its body component. – Aman Nov 22 '18 at 07:53
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.

grexlort
  • 875
  • 1
  • 12
  • 18
  • 2
    A shorter dirty solution `return new Response("")`. This is nice when you have actions that run but don't have to output anything – Tomás Cot May 19 '17 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

andylondon
  • 176
  • 6
  • 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 Jun 28 '17 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.

Daniel
  • 1,352
  • 1
  • 14
  • 16
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.

rvaliev
  • 1,051
  • 2
  • 12
  • 31
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).

Matthew Player
  • 318
  • 4
  • 17