Symfony2,如何在主`Environment`对象上使用`addExtension()`方法注册扩展

PMo*_*bed 16 symfony twig

我想在symfony2项目中加载一个新的扩展,twig但我不知道我应该在哪里放下线来工作:

$twig = new Twig_Environment($loader, $config);
$twig->addExtension(new Twig_Extension_Debug());
Run Code Online (Sandbox Code Playgroud)

http://twig.sensiolabs.org/doc/functions/dump.html的任何教程?

PMo*_*bed 24

我可以为twig添加调试,如下所示:

# app/config/config.yml
services:
    acme_hello.twig.extension.debug:
        class:        Twig_Extension_Debug
        tags:
             - { name: 'twig.extension' }
Run Code Online (Sandbox Code Playgroud)

看看这里的更多细节;