This WordPress plugin is a wrapper for the Kint PHP Debugger utility. Now instead of using var_dump() or print_r(), you simply use d() with zero, nadda, no formatting required.
Some handy tools just for the PHP Developer:
d( $var );to render a collapsible UI container which displays your variable data in “the most informative way”
ddd( $var );same as d() except that it also executes
die()to halt execution.
See the screenshot 1 for more details.
Here are some variations of d() to give you the display you want:
- ‘~d( $var );’ outputs in plain text format.
- ‘+d( $var );’ disregards depth level limits and outputs everything
- ‘!d( $var );’ shows expanded rich output
- ‘-d( $var );’ attempts to ob_clean() the previous output (dump something inside of HTML)
Kint even includes a naïve profiler, which can help you analyze which blocks of code take longer than others:
Kint::dump( microtime() ); // just pass microtime()
sleep( 1 );
Kint::dump( microtime(), ‘after sleep(1)’ );
sleep( 2 );
ddd( microtime(), ‘final call, after sleep(2)’ );
See screenshot 2 for what is rendered out in your browser.
- How do I use this utility?
When you are testing your code, you use d( $var ) in place of var_dump( $var ) and print_r( $var ). No need to wrap it in pre’s either.
- What does it render in the browser?
Kint provides a handy UI that wraps up the data within the variable. Click to open it up and see the data.
See the screenshot 1 for an example.
- What else does Kint provide to help me debug?
As you can see the screenshot 1, besides the handy UI, it also provides you with a full call stack. Click on the text below the UI to expand it out.
- Can I run this on a live site?
I wouldn’t unless you are testing. This tool is for debug only. Once you push the site live, deactivate and delete this plugin.
- What should I do when the site goes live?
Deactivate and delete this plugin.
Thanks for this plugin. It makes debugging my arrays of arrays of arrays much simpler. 😉
Really like to debug with Kint, and this plugin makes it much easier.
- Upgraded Kint to v1.0.10
- First release