Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save JPustkuchen/a5f1eaeb7058856b7ef087b028ffdfeb to your computer and use it in GitHub Desktop.
Save JPustkuchen/a5f1eaeb7058856b7ef087b028ffdfeb to your computer and use it in GitHub Desktop.
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)

Kint ^3:

// 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;
}

Kint >=4:

// Change kint maxLevels setting:
if (class_exists('Kint')) {
  \Kint::$depth_limit = 5;
}
@djassie
Copy link

djassie commented Apr 13, 2023

wokring -

if (class_exists('Kint')) {
  // Set the max_depth to prevent out-of-memory.
  \Kint::$max_depth = 4;
}

@djdemonNet
Copy link

Kint ^5 has the same syntax as and Kint ^4

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment