View layer pattern where you only present what you have been given is fine and all, but how do you know what is available? Is there a \"list all defined variables\" function
Since Symfony >= 2.6, there is a nice VarDumper component, but it is not used by Twig's dump()
function.
To overwrite it, we can create an extension:
In the following implementation, do not forget to replace namespaces.
Fuz/AppBundle/Resources/config/services.yml
parameters:
# ...
app.twig.debug_extension.class: Fuz\AppBundle\Twig\Extension\DebugExtension
services:
# ...
app.twig.debug_extension:
class: %app.twig.debug_extension.class%
arguments: []
tags:
- { name: twig.extension }
Fuz/AppBundle/Twig/Extension/DebugExtension.php