Outputting PHP “var_dump” code debug capability inside Twig templates

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):

Step 2:  Inside any Twig template, you can “var_dump” variables using the Twig Debug Extension:

– Aaron Belchamber

Aaron Belchamber has written 243 articles

Leave a Reply

Your email address will not be published. Required fields are marked *