How to Print Variables using Kint in Drupal 8

When you start tinkering with a module or a theme in Drupal, eventually you’ll need to print a variable to see what’s inside.

Now in PHP you have var_dump and print_r but these functions aren’t the easiest to work with. When used they print the variable fully expanded, making it hard to filter or find anything.

In the Devel module for Drupal 7, you have the dpm and dsm which printed variables using the Krumo library. For Drupal 8, however, this library has been replaced with a more modern and maintained library called Kint.

In the latest tutorial over at WebWash, learn how to print variables within Php and the Twig template using Kint.

Link: How to Print Variables using Kint in Drupal 8

Leave a Reply

Your email address will not be published. Required fields are marked *