Adds Kint, an in-app PHP debugger, to Craft CMS for use in Twig and PHP.
To install Kint, follow these steps:
- Download & unzip the file and place the
kint
directory into yourcraft/plugins
directory - -OR- do a
git clone https://github.com/mildlygeeky/craft_kint.git
directly into yourcraft/plugins
folder. You can then update it withgit pull
- Install plugin in the Craft Control Panel under Settings > Plugins
Kint works on Craft 2.4.x and Craft 2.5.x.
Kint is an interactive debugger for PHP applications. Full documentation is available at http://raveren.github.io/kint/.
Its advantages include that it can be run out of devMode (though you would not want to use it in a public setting), and it is interactive, with keyboard shortcuts to expand and collapse objects, separates content from methods, etc.
No configuration required, but you can set the theme that Kint will use within the plugin's settings screen.
{{ d(someTwigVariable) }}
or {{ craft.kint.d(someTwigVariable) }}
This is the simplest usage, and will output an interactive debugger for the variable passed in.
{{ dd(someTwigVariable) }}
or {{ craft.kint.dd(someTwigVariable) }}
This works the same way as the d (dump) command, except it will cause output to end immediately after the debugger is returned.
{{ s(someTwigVariable) }}
or {{ craft.kint.s(someTwigVariable) }}
This works essentially the same way as the built-in Twig dump method, and returns a plain text debugging output.
{{ sd(someTwigVariable) }}
or {{ craft.kint.sd(someTwigVariable) }}
Same as above, but with output ending immediately after the plain text debugging output is returned.
{{ time() }}
or {{ craft.kint.time }}
Basic reporting of memory usage at the time that the command is run, as well as a timestamp. If used multiple times, it will also report the time since it was last called and average duration.
All of the above functions are also exposed through services, though Kint does put its functions into PHP un-namespaced as well. In the future I may try to fork it and just expose everything though one central object to keep things clean.
- Initial release
- Fixed issue that caused crash when a theme was not selected from settings page
- Fixed issue where raw JS could be shown on page if script tags with double-quotes were used
- Removed reference to Kint's path being included below the debugger
- Added Twig functions
d
,dd
,s
,sd
, andtime
for easier usage
- Thank you to Rokas Šleinius, the developer of Kint - he welcomes donations at Kint's website
- Icon created by Lemon Liu from the Noun Project
Brought to you by Mildly Geeky