Symfony2, How to register an extension by using the `addExtension()` method on your main `Environment` object

symfony, twig

Solution

I could add debug for twig like below :

# app/config/config.yml
services:
    acme_hello.twig.extension.debug:
        class:        Twig_Extension_Debug
        tags:
             - { name: 'twig.extension' }

Look here for more details;

Problem

I would like to load a new extension in a `symfony2` project for `twig` but I don't know where should I put line below to work : ``` $twig = new Twig_Environment($loader, $config); $twig->addExtension(new Twig_Extension_Debug()); ``` Any tutorials for http://twig.sensiolabs.org/doc/functions/dump.html ?

Original source