Quick tips on using Devel and Kint for Drupal 8 debugging

Posted on January 20, 2016

In the Drupal 8 Devel module, a wrapper for the Kint debugging tool is included. This needs to be enabled in addition to Devel, and provides a stylish replacement for the Krumo output found in the Drupal 7 version.

To debug variables and objects withDevel and Kint, use one of various print methods: dpm(), dsm(), kpr(), kprint_r() in core or contrib (php) code:

Example:

<?php
    dsm($object);
?>

Navigation tips are found in the Kint documentation, but some of the most useful for quick navigation are:

Click anywhere in the collapsed area to show contents. If using keyboard navigation, press right arrow (Enable keyboard navigation first by pressing “d”):

Collapsed Object in Kint

 

Click the plus sign to expand all subs. If using keyboard navigation (Enabled with “d”), press the right arrow key twice:

Expanded Object in Kint

 

Click the arrow to the right to open a sub object or array in a new window:

Kint open sub object in new window