Drupal 8 or Drupal 9 – how to enable Devel Kint again and display available methods

For Drupal 9 is not possible to install module devel version 8.x-2.1. It has been replaced with version 4.0.0, but without submodule Kint. But there is custom module Devel Kint Extras with original functionality.

Our goal is simple – we need to display again available objects method as it was for Drupal 8 using module Devel and Kint submodule. New version 4.0.0 – only one compatible with Drupal 9 – removed this Kint submodule: Remove Kint module and create a kint dumper plugin in devel" https://www.drupal.org/project/devel/issues/2839515

In the release notes for 4.0.0 https://www.drupal.org/project/devel/releases/4.0.0 you can find note that you must install composer require kint-php/kint to get Kint back. But this works only partly, because it doesn’t show available methods, it works like classic simple dump.

33Kint missing methods

But all this solves module Devel Kint Extras https://www.drupal.org/project/devel_kint_extras.

Installation & Configuration

First step is to install both modules – Devel and Devel Kint Extras. Easiest way for it is to use composer. Second module – Devel Kint Extras – will also install required project kint-php.

Note: At this point I've got problems because of missing correct Devel version, because I had previously 4.x-dev version of the module. Solution was easy - remove folder web/modules/contrib/devel and install it again with composer.

33Kint missing dependency

On the "Devel settings" page /admin/config/development/devel we switch to "Kint extended" dumper – and that’s all.

33Kint with methods

Dump of user entity – ksm($account); – display also Available methods and Static class properties, which is exactly what we wanted to achieve 

33Devel dumper

Note: you must use ksm() or dpm(), not kint().

There is settings for Kint how to limit depth of report to avoid memory problems. In the file web/sites/default/settings.php (orsettings.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;
}
https://gist.github.com/JPustkuchen/a5f1eaeb7058856b7ef087b028ffdfeb#gi…

Final words

Thanks to module Devel Kint Extras we’ve easily put back functionality of the previous versions of modules Devel and Kint from Drupal 8.