Enable Debug mode in Twig Template

Sometimes you need to see your variables or object in Twig template before printing it out. So to enable debug mode in twig template system you just need to tweak few settings upon initializing twig environment. Just follow the below code where I initiated Twig environment with debug mode.

$twig = new Twig_Environment($loader, array(
    'debug' => true,
    // ...
$twig->addExtension(new Twig_Extension_Debug());


And inside your template where you want to dump the variable just write “. You can read more about dump function twig template from here

Shaharia is a professional software engineer with more than 10 years of experience in the relevant fields. Digital ad certified, cloud platform architect, Big data enthusiasts, tech early adopters.

Site Footer