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