Backend Development

Debug with KINT!

If you're developing PHP and have to debug, don't just rely on var_dump(). Use the different debug tools out there!

One of the debug tools I find easy and great to use is KINT!
You can install kint by going here HERE

Here are examples on how we can use kint:

Basic way to use kint
  // Example variable
  $user = \Drupal\user\Entity\User::load(0);
  Kint::dump($user); 
  // or use the shorthand
  d($user);

It will display 

You can then explore the object with its methods, properties and arrays inside it!

Sometimes the variable you are trying to debug might be too big, which will cause your browser to slow down.
You can solve that by adjusting the debth of your kint by

Kint::$max_depth = 4;

Acret PH

Updated : January 8, 2024 Created : October 16, 2020