Kint

Zero-setup replacement for var_dump(), print_r(), and debug_backtrace().

Kint - a modern and powerful PHP debugging helper

What is it?

Kint for PHP is a tool designed to present your debugging data in the absolutely best way possible.

In other words, it’s var_dump() and debug_backtrace() on steroids. Easy to use, but powerful and customizable. An essential addition to your development toolbox.

Still lost? You use it to see what’s inside variables.

Install with composer

composer require kint-php/kint
<?php

include 'vendor/autoload.php';

d('Dumped with Kint');

Install a phar file

<?php

// Found in the build folder
include 'kint.phar';

d('Dumped with Kint');

Basic usage

<?php

Kint::dump($GLOBALS, $_SERVER); // Dump any number of variables
d($GLOBALS, $_SERVER); // d() is a shortcut for Kint::dump()

Kint::trace(); // Dump a backtrace

Kint::$enabled_mode = false; // Disable kint

Live demo

You have some data and you need to get more data out of it, but you don’t know how the data is structured until you poke around inside it.

<?php

$time = get_mysterious_value();
$data = get_mysterious_data();
$object = get_mysterious_object();

include 'kint.phar';

d($time, $data, $object);

Github pages don’t support PHP so this output was pre-recorded

$time integer 1486849709
2017-02-11 21:48:29 UTC
$data string (740) "eyJjb2xvciI6InJnYmEoMjU1LCAyNTUsIDAsIDAuNSkiLCJkYXRhIjpbeyJ1c2VybmFtZSI6Im1v...
  • Base64
  • Contents
  • base64_decode($data) string (555) "{"color":"rgba(255, 255, 0, 0.5)","data":[{"username":"monkey","created":"20...
    base64_decode($data)
    • Json (2)
    • Contents
    • color => string (22) "rgba(255, 255, 0, 0.5)"
      json_decode(base64_decode($data), true)['color']
      yellow
      #FF0
      #FFFF00
      #FFFF0080
      rgba(255, 255, 0, 0.5)
      hsla(60, 100%, 50%, 0.5)
      
      data => array (6)
      json_decode(base64_decode($data), true)['data']
      • Table (6)
      • Contents (6)
      • usernamecreatedlastlog
        0monkey2017-01-25 22:24:082017-01-28 14:49:51
        1tiger2017-01-03 11:40:502017-01-09 17:44:48
        2mantis2017-01-03 12:19:482017-01-10 14:46:51
        3snake2017-01-11 22:15:252017-02-06 01:45:46
        4crane2017-01-09 22:28:342017-01-22 00:12:26
        5panda2017-01-14 13:20:402017-01-27 23:14:40
      • 0 => array (3)
        json_decode(base64_decode($data), true)['data'][0]
        username => string (6) "monkey"
        json_decode(base64_decode($data), true)['data'][0]['username']
        created => string (19) "2017-01-25 22:24:08"
        json_decode(base64_decode($data), true)['data'][0]['created']
        lastlog => string (19) "2017-01-28 14:49:51"
        json_decode(base64_decode($data), true)['data'][0]['lastlog']
        1 => array (3)
        json_decode(base64_decode($data), true)['data'][1]
        username => string (5) "tiger"
        json_decode(base64_decode($data), true)['data'][1]['username']
        created => string (19) "2017-01-03 11:40:50"
        json_decode(base64_decode($data), true)['data'][1]['created']
        lastlog => string (19) "2017-01-09 17:44:48"
        json_decode(base64_decode($data), true)['data'][1]['lastlog']
        2 => array (3)
        json_decode(base64_decode($data), true)['data'][2]
        username => string (6) "mantis"
        json_decode(base64_decode($data), true)['data'][2]['username']
        created => string (19) "2017-01-03 12:19:48"
        json_decode(base64_decode($data), true)['data'][2]['created']
        lastlog => string (19) "2017-01-10 14:46:51"
        json_decode(base64_decode($data), true)['data'][2]['lastlog']
        3 => array (3)
        json_decode(base64_decode($data), true)['data'][3]
        username => string (5) "snake"
        json_decode(base64_decode($data), true)['data'][3]['username']
        created => string (19) "2017-01-11 22:15:25"
        json_decode(base64_decode($data), true)['data'][3]['created']
        lastlog => string (19) "2017-02-06 01:45:46"
        json_decode(base64_decode($data), true)['data'][3]['lastlog']
        4 => array (3)
        json_decode(base64_decode($data), true)['data'][4]
        username => string (5) "crane"
        json_decode(base64_decode($data), true)['data'][4]['username']
        created => string (19) "2017-01-09 22:28:34"
        json_decode(base64_decode($data), true)['data'][4]['created']
        lastlog => string (19) "2017-01-22 00:12:26"
        json_decode(base64_decode($data), true)['data'][4]['lastlog']
        5 => array (3)
        json_decode(base64_decode($data), true)['data'][5]
        username => string (5) "panda"
        json_decode(base64_decode($data), true)['data'][5]['username']
        created => string (19) "2017-01-14 13:20:40"
        json_decode(base64_decode($data), true)['data'][5]['created']
        lastlog => string (19) "2017-01-27 23:14:40"
        json_decode(base64_decode($data), true)['data'][5]['lastlog']
    • {"color":"rgba(255, 255, 0, 0.5)","data":[{"username":"monkey","created":"2017-01-25 22:24:08","lastlog":"2017-01-28 14:49:51"},{"username":"tiger","created":"2017-01-03 11:40:50","lastlog":"2017-01-09 17:44:48"},{"username":"mantis","created":"2017-01-03 12:19:48","lastlog":"2017-01-10 14:46:51"},{"username":"snake","created":"2017-01-11 22:15:25","lastlog":"2017-02-06 01:45:46"},{"username":"crane","created":"2017-01-09 22:28:34","lastlog":"2017-01-22 00:12:26"},{"username":"panda","created":"2017-01-14 13:20:40","lastlog":"2017-01-27 23:14:40"}]}
      
  • eyJjb2xvciI6InJnYmEoMjU1LCAyNTUsIDAsIDAuNSkiLCJkYXRhIjpbeyJ1c2VybmFtZSI6Im1vbmtleSIsImNyZWF0ZWQiOiIyMDE3LTAxLTI1IDIyOjI0OjA4IiwibGFzdGxvZyI6IjIwMTctMDEtMjggMTQ6NDk6NTEifSx7InVzZXJuYW1lIjoidGlnZXIiLCJjcmVhdGVkIjoiMjAxNy0wMS0wMyAxMTo0MDo1MCIsImxhc3Rsb2ciOiIyMDE3LTAxLTA5IDE3OjQ0OjQ4In0seyJ1c2VybmFtZSI6Im1hbnRpcyIsImNyZWF0ZWQiOiIyMDE3LTAxLTAzIDEyOjE5OjQ4IiwibGFzdGxvZyI6IjIwMTctMDEtMTAgMTQ6NDY6NTEifSx7InVzZXJuYW1lIjoic25ha2UiLCJjcmVhdGVkIjoiMjAxNy0wMS0xMSAyMjoxNToyNSIsImxhc3Rsb2ciOiIyMDE3LTAyLTA2IDAxOjQ1OjQ2In0seyJ1c2VybmFtZSI6ImNyYW5lIiwiY3JlYXRlZCI6IjIwMTctMDEtMDkgMjI6Mjg6MzQiLCJsYXN0bG9nIjoiMjAxNy0wMS0yMiAwMDoxMjoyNiJ9LHsidXNlcm5hbWUiOiJwYW5kYSIsImNyZWF0ZWQiOiIyMDE3LTAxLTE0IDEzOjIwOjQwIiwibGFzdGxvZyI6IjIwMTctMDEtMjcgMjM6MTQ6NDAifV19
    
$object MysteriousObject#2 (2)
  • Properties (2)
  • Available methods
  • Static class properties
Called from <ROOT>/demo.php:9 [d()]

Let’s take a look at this data with Kint

  • Click anywhere on the bar to unfold it
  • Double click + to unfold all children
  • Press d to toggle keyboard navigation.
  • Press the “” icon on the right to see what code you’d need to use to get at a piece of data.
  • Press the “” icon on the right to open a live search.
  • Change tabs to see different views of data.
  • You can sort tables of data by clicking on the headers.

  • Kint automatically detects, unpacks, and parses common formats like XML, base64, serialize, and JSON
  • Detects common patterns like colors, filenames, tables, and timestamps and displays extra information about them
  • Provides the user with the exact piece of code they need to access some information nested deep in the hierarchy

Advanced usage »