Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Drupal 8 kint set maxLevels in settings.php to prevent out of memory

Currently devel doesn't allow to override KINT configuration in a clean way. Hopefully this will be possible some day via setting in UI or drupal setting override in settings.php Until this happens you may use this dirty trick in settings.php to override the setting.

See issues:

Simply copy this into your settings.php and change the value accordingly (Kint default: 7)

// Change kint maxLevels setting:
include_once(DRUPAL_ROOT . '/modules/contrib/devel/kint/kint/Kint.class.php');
if(class_exists('Kint')){
  // Set the maxlevels to prevent out-of-memory. Currently there doesn't seem to be a cleaner way to set this:
  Kint::$maxLevels = 4;
}
@JPustkuchen

This comment has been minimized.

Copy link
Owner Author

@JPustkuchen JPustkuchen commented Feb 15, 2018

I think a dynamic path (get devel module path from service) isn't possible at this very early point in bootstrap?

@leymannx

This comment has been minimized.

Copy link

@leymannx leymannx commented Apr 24, 2020

There's also https://www.drupal.org/project/devel/issues/2405179 and this patch https://www.drupal.org/files/issues/2018-10-09/make-dumper-plugins-configurable-2405179-16.patch and then you could put $settings['kint_maxLevels'] = '4'; into your settings.php

@leymannx

This comment has been minimized.

Copy link

@leymannx leymannx commented Apr 24, 2020

Ah now I see it's also you who already commented in that issue.

@leymannx

This comment has been minimized.

Copy link

@leymannx leymannx commented Jun 29, 2020

Now with Devel 4.x and kint-php as dependency the include must be removed and maxLevels becomes max_depth. The new default is 6. So in settings(.local).php put:

// Change kint max_depth setting.
if (class_exists('Kint')) {
  // Set the max_depth to prevent out-of-memory.
  \Kint::$max_depth = 4;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.