Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Twig: adding twig extension debug from config file

Tags:

php

twig

symfony

According to TWIG documentation, in order to use the dump function I should first add the extension debug like so:

$twig = new Twig_Environment($loader, array(
'debug' => true,
// ...
 ));
$twig->addExtension(new Twig_Extension_Debug());

But how do I do that from config.yml ? I use symfony2.

like image 273
Sam Avatar asked Sep 17 '25 12:09

Sam


1 Answers

It should be defined as follow,

# app/config/config.yml
services:
    custom.twig.extension.debug:
        class: Twig_Extension_Debug
        tags:
             - { name: 'twig.extension' }
like image 186
Ahmed Siouani Avatar answered Sep 20 '25 02:09

Ahmed Siouani