3

in /var/aegir/platforms/drupal8-dev/sites/my_site_uri/settings.php

  # Additional site configuration settings.
  if (is_readable('/var/aegir/platforms/drupal8-dev/sites/my_site_uri/local.settings.php')) {
    include_once('/var/aegir/platforms/drupal8-dev/sites/my_site_uri/local.settings.php');
  }

in /var/aegir/platforms/drupal8-dev/sites/my_site_uri/local.settings.php

       <?php # local settings.php

$settings['container_yamls'][] =DRUPAL_ROOT . '/sites/default/services.yml';

in /var/aegir/platforms/drupal8-dev/sites/default/services.yml

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

The firebug console comments are working meaning twig debug is activated but dump (twig debug extension ) is not working . why? is there anything more to set in services.yml ?

  {{ dump() }}
1
  • The config mentioned above actually enables the dump twig function, but you might get a white screen of death for large objects. You can try {{ dump('juast a string') }} and see if it outputs somethig. More details below.
    – Andreas
    Commented Mar 16, 2021 at 12:24

4 Answers 4

3

Turn on Twig debugging by:

Copy sites/example.settings.local.php and rename to sites/default/settings.local.php

Go to sites/default/settings.php and uncomment the code below the comment relating to "Local development override configuration" and save the file.

if (file_exists(__DIR__ . '/settings.local.php')) {
  include __DIR__ . '/settings.local.php';
}

Open sites/development.services.yml in a text editor and add the following to the bottom of the file and then save the file

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

Note: use two spaces for each indent. Twig can be fussy with this.

The debugging will be visible as html comments in the source code. Use Chrome or other developer tools to inspect.

If you want to inspect the data structure of variables in a speciifc template, install Devel module and enable Devel and Devel Kint and then add this in your template:

# to dump everything
{{ kint() }}


# to dump a variable
{{ kint(page) }}


# to dump lower down in the data structure
{{ kint(page.content) }}
2
  • twig debugging is working as i say in my msg. but the dump function is not working twig.sensiolabs.org/doc/functions. As for kint i have activated devel kint module and putting {{ kint() }} gives me a WSOD with nothing in the logs !?
    – Matoeil
    Commented Oct 28, 2016 at 8:09
  • 1
    Apologies for my detailed answer. I meant for you to check your settings against my answer. I found this post where someone was having and out of memory issue (and suggested solution) because dump or kint was too large. drupal.stackexchange.com/questions/204598/…
    – user68786
    Commented Oct 29, 2016 at 6:35
1

try

$settings['container_yamls'][] = DRUPAL_ROOT . '/sites/my_site_uri/services.yml';

or to keep it more generic:

$settings['container_yamls'][] = __DIR__ . '/services.yml';
1
1

As for kint i have activated devel kint module and putting {{ kint() }} gives me a WSOD with nothing in the logs !??

I had the same problem as mentioned here, the solution is:

According to Devel maintainer willzyx:

you can edit modules/devel/kint/kint/config.default.php and set $_kintSettings['maxLevels'] to a lower number (the default is 7)

So try lowering it to 5 or 4.

0

In addition to my comment above - the dump twig function is available, if in the twig.config:debug is set to true (as mentioned already in the original question)

If enabled, you can try {{ dump('just a string') }} in your template, and it should output the correct value.

However, according to this article it is pretty likely, that you'll end up with a whitescreen of death due to a out of memory exception if you try to debug a complex class like node or _context. To get around this, you can try something like:

{{ dump(_context|keys) }}

This will at least give some insight of what can be accessed.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.