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)
username created lastlog 0 monkey 2017-01-25 22:24:08 2017-01-28 14:49:51 1 tiger 2017-01-03 11:40:50 2017-01-09 17:44:48 2 mantis 2017-01-03 12:19:48 2017-01-10 14:46:51 3 snake 2017-01-11 22:15:25 2017-02-06 01:45:46 4 crane 2017-01-09 22:28:34 2017-01-22 00:12:26 5 panda 2017-01-14 13:20:40 2017-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']
- ⇄username => string (6) "monkey"
- ⇄⧉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']
- ⇄username => string (5) "tiger"
- ⇄⧉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']
- ⇄username => string (6) "mantis"
- ⇄⧉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']
- ⇄username => string (5) "snake"
- ⇄⧉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']
- ⇄username => string (5) "crane"
- ⇄⧉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']
- ⇄username => string (5) "panda"
- ⇄⧉0 => array (3)
- ⇄⧉color => string (22) "rgba(255, 255, 0, 0.5)"
{"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"}]}
- ⇄⧉base64_decode($data) string (555) "{"color":"rgba(255, 255, 0, 0.5)","data":[{"username":"monkey","created":"20...
eyJjb2xvciI6InJnYmEoMjU1LCAyNTUsIDAsIDAuNSkiLCJkYXRhIjpbeyJ1c2VybmFtZSI6Im1vbmtleSIsImNyZWF0ZWQiOiIyMDE3LTAxLTI1IDIyOjI0OjA4IiwibGFzdGxvZyI6IjIwMTctMDEtMjggMTQ6NDk6NTEifSx7InVzZXJuYW1lIjoidGlnZXIiLCJjcmVhdGVkIjoiMjAxNy0wMS0wMyAxMTo0MDo1MCIsImxhc3Rsb2ciOiIyMDE3LTAxLTA5IDE3OjQ0OjQ4In0seyJ1c2VybmFtZSI6Im1hbnRpcyIsImNyZWF0ZWQiOiIyMDE3LTAxLTAzIDEyOjE5OjQ4IiwibGFzdGxvZyI6IjIwMTctMDEtMTAgMTQ6NDY6NTEifSx7InVzZXJuYW1lIjoic25ha2UiLCJjcmVhdGVkIjoiMjAxNy0wMS0xMSAyMjoxNToyNSIsImxhc3Rsb2ciOiIyMDE3LTAyLTA2IDAxOjQ1OjQ2In0seyJ1c2VybmFtZSI6ImNyYW5lIiwiY3JlYXRlZCI6IjIwMTctMDEtMDkgMjI6Mjg6MzQiLCJsYXN0bG9nIjoiMjAxNy0wMS0yMiAwMDoxMjoyNiJ9LHsidXNlcm5hbWUiOiJwYW5kYSIsImNyZWF0ZWQiOiIyMDE3LTAxLTE0IDEzOjIwOjQwIiwibGFzdGxvZyI6IjIwMTctMDEtMjcgMjM6MTQ6NDAifV19
- ⧉⌕$object MysteriousObject#3 (2)
- Properties (2)
- Available methods
- Static class properties
- ⇄⧉public definition -> string (143) "<?xml version="1.0"?> <Mystery created="2022-11-10 22:33:28"> <Name>Mysterio...$object->definition
- XML
- Contents
- ⇄⧉Mystery SimpleXMLElement#88 (2)simplexml_load_string($object->definition)
- Children (2)
- Attributes
- ⇄Name SimpleXMLElement#73 "Mysterio"simplexml_load_string($object->definition)->children()->Name
- ⇄⧉Value SimpleXMLElement#53 "Object"simplexml_load_string($object->definition)->children()->Value
- Contents
- Attributes
Object
- ⇄type => SimpleXMLElement#162 "mysterious"(string) simplexml_load_string($object->definition)->children()->Value->attributes()['type']
- ⇄type => SimpleXMLElement#162 "mysterious"
- ⇄Name SimpleXMLElement#73 "Mysterio"
- ⇄created => SimpleXMLElement#83 "2022-11-10 22:33:28"(string) simplexml_load_string($object->definition)->attributes()['created']
- ⇄created => SimpleXMLElement#83 "2022-11-10 22:33:28"
- ⇄⧉Mystery SimpleXMLElement#88 (2)
<?xml version="1.0"?> <Mystery created="2022-11-10 22:33:28"> <Name>Mysterio</Name> <Value type="mysterious">Object</Value> </Mystery>
- ⧉protected created -> DateTime#4 (3) 2022-11-10 22:33:28+01:00 CET
- Properties (3)
- Available methods (20)
- Static class properties (13)
- public date -> string (26) "2022-11-10 22:33:28.000000"
- public timezone_type -> integer 3
- public timezone -> string (13) "Europe/Berlin"
- public __wakeup()
- public format(string $format)
- public modify(string $modifier)
- public add(DateInterval $interval)
- public sub(DateInterval $interval)
- public getTimezone()
- public getOffset()
- public setTimestamp(int $timestamp)
- public getTimestamp()
- public static __set_state(array $array)
- ⇄public static createFromImmutable(DateTimeImmutable $object)\DateTime::createFromImmutable(DateTimeImmutable $object)
- ⇄public static createFromInterface(DateTimeInterface $object): DateTime\DateTime::createFromInterface(DateTimeInterface $object)
- ⇄public static createFromFormat(string $format, string $datetime, ?DateTimeZone $timezone = null)\DateTime::createFromFormat(string $format, string $datetime, ?DateTimeZone $timezone = null)
- ⇄public static getLastErrors()\DateTime::getLastErrors()
- ⇄public const ATOM :: string (13) "Y-m-d\TH:i:sP"\DateTime::ATOM
- ⇄public const COOKIE :: string (16) "l, d-M-Y H:i:s T"\DateTime::COOKIE
- ⇄public const ISO8601 :: string (13) "Y-m-d\TH:i:sO"\DateTime::ISO8601
- ⇄public const RFC822 :: string (16) "D, d M y H:i:s O"\DateTime::RFC822
- ⇄public const RFC850 :: string (16) "l, d-M-y H:i:s T"\DateTime::RFC850
- ⇄public const RFC1036 :: string (16) "D, d M y H:i:s O"\DateTime::RFC1036
- ⇄public const RFC1123 :: string (16) "D, d M Y H:i:s O"\DateTime::RFC1123
- ⇄public const RFC7231 :: string (21) "D, d M Y H:i:s \G\M\T"\DateTime::RFC7231
- ⇄public const RFC2822 :: string (16) "D, d M Y H:i:s O"\DateTime::RFC2822
- ⇄public const RFC3339 :: string (13) "Y-m-d\TH:i:sP"\DateTime::RFC3339
- ⇄public const RFC3339_EXTENDED :: string (15) "Y-m-d\TH:i:s.vP"\DateTime::RFC3339_EXTENDED
- ⇄public const RSS :: string (16) "D, d M Y H:i:s O"\DateTime::RSS
- ⇄public const W3C :: string (13) "Y-m-d\TH:i:sP"\DateTime::W3C
- ⇄public const ATOM :: string (13) "Y-m-d\TH:i:sP"
- ⇄⧉public definition -> string (143) "<?xml version="1.0"?> <Mystery created="2022-11-10 22:33:28"> <Name>Mysterio...
- ⇄⧉public define(string $definition): void$object->define(string $definition)
Defined in <ROOT>/demoload.php:58
- ⇄⧉public define(string $definition): void
- private static $loaded :: boolean true
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