Enable Twig debug in Symfony2

To enable the debug tag in Twig, add the following to app/config/config_dev.yml

services:
    twig.extension.debug:
        class: Twig_Extensions_Extension_Debug
        tags:
            - { name: twig.extension }

Afterwards clear the cache and use the debug extension:

{% debug my_var %}

Sources

  • Yerbol Kuandykoff

    ParseException: Unable to parse in “…/config.yml” at line … (near ” tags:”).

  • http://twitter.com/wolf_wolker Noel Garcia

    Little mistake, tags should be at the same level than class