Twig comes with its own Debug extension to allow users to output “var_dump()” — the function that spits out the raw values behind a PHP variable, array or object — inside a Twig template. This functions is helpful in the dev environment while trying to debug code.
Step 1: Add the following to the /app/config/config_dev.yml (don’t add this to config_prod.yml):
twig: debug: 1 services: debug.twig.extension: class: Twig_Extensions_Extension_Debug tags: [{ name: 'twig.extension' }]Step 2: Inside any Twig template, you can “var_dump” variables using the Twig Debug Extension:
{% debug varName %}– Aaron Belchamber