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
twig.extension
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