Download the PHP package youssef/debug without Composer
On this page you can find all versions of the php package youssef/debug. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download youssef/debug
More information about youssef/debug
Files in youssef/debug
Package debug
Short Description Kint - debugging helper for PHP developers
License MIT
Homepage https://github.com/raveren/kint
Informations about the package debug
Kint - debugging helper for PHP developers
What am I looking at?
At first glance Kint is just a pretty replacement for var_dump(), print_r() and debug_backtrace().
However, it's much, much more than that. Even the excellent xdebug
var_dump improvements don't come close - you will eventually wonder how you developed without it.
Just to list some of the most useful features:
- The variable name and file + line where Kint was called from is displayed;
- You can disable all Kint output easily and on the fly - so you can even debug live systems without anyone knowing (even though you know you shouldn't be doing that!:).
- CLI is detected and formatted for automatically (but everything can be overridden on the fly) - if your setup supports it, the output is colored too:
- Debug backtraces are finally fully readable, actually informative and a pleasure to the eye.
- Kint has been in active development since 2010 and is shipped with Drupal 8 by default as part of its devel suite. You can trust it not being abandoned or getting left behind in features.
- Variable content is displayed in the most informative way - and you never, ever miss anything! Kint guarantees you see every piece of physically available information about everything you are dumping*;
- in some cases, the content is truncated where it would otherwise be too large to view anyway - but the user is always made aware of that;
- Some variable content types have an alternative display - for example you will be able see
JSON
in its raw form - but also as an associative array:
There are more than ten custom variable type displays inbuilt and more are added periodically.
Installation and Usage
One of the main goals of Kint is to be zero setup.
Download the archive and simply
Or, if you use Composer:
Or just run composer require raveren/kint
That's it, you can now use Kint to debug your code:
Note, that Kint does have configuration (like themes and IDE integration!), but it's in need of being rewritten, so I'm not documenting it yet.
Tips & Tricks
- Kint is enabled by default, call
Kint::enabled(false);
to turn its funcionality completely off. The best practice is to enable Kint in DEVELOPMENT environment only (or for exampleKint::enabled($_SERVER['REMOTE_ADDR'] === '<your IP>');
) - so even if you accidentally leave a dump in production, no one will know. sd()
andddd()
are shorthands fors();die;
andd();die;
respectively.- Kint has keyboard shortcuts! When Kint is visible, press D on the keyboard and you will be able to traverse the tree with arrows and tab keys - and expand/collapse nodes with space or enter.
- Double clicking the
[+]
sign in the output will expand/collapse ALL nodes; triple clicking big blocks of text will select it all. -
To catch output from Kint just assign it to a variablebeta
- There are a couple of real-time modifiers you can use:
~d($var)
this call will output in plain text format.+d($var)
will disregard depth level limits and output everything (careful, this can hang your browser on huge objects)!d($var)
will show expanded rich output.-d($var)
will attempt toob_clean
the previous output so if you're dumping something inside a HTML page, you will still see Kint output. You can combine modifiers too:~+d($var)
-
To force a specific dump output type just pass it to the
Kint::enabled()
method. Available options are:Kint::MODE_RICH
(default),Kint::MODE_PLAIN
,Kint::MODE_WHITESPACE
andKint::MODE_CLI
: - To change display theme, use
Kint::$theme = '<theme name>';
where available options are:'original'
(default),'solarized'
,'solarized-dark'
and'aante-light'
. Here's an (outdated) preview:
-
Kint also includes a naïve profiler you may find handy. It's for determining relatively which code blocks take longer than others:
- See the tiny arrows on the right of the output? Click them (not in the image though :) to open its parent node in a separate browser window.
Author
Rokas Šleinius (raveren)
License
Licensed under the MIT License