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

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


I could add debug for twig like below :

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

Look here for more details;


You have to create a service with twig.extension tag. See here


There is also a cookbook on Symfony documentation about how to create a custom twig extension for Symfony.

You can take a look at it right here

Regards,
Matt