Enable Twig debugging with a query parameter

Here's how I set the twig.config debug parameter using a URL query string . I got the idea from https://julian.pustkuchen.com/node/795 .

In settings.local.php, add the following:

<?php
if (isset($_REQUEST['DEBUG'])) {
  include __DIR__ . '/settings.local.debug.php';
}

In settings.local.debug.php, add the following:

 

<?php
$settings['container_yamls'][] = __DIR__ . '/services.local.debug.yml';

In services.local.debug.yml, add the following:

parameters:
  twig.config:
    debug: true
    cache: false

External References

Article Type

General