Adds Kint, an in-app PHP debugger, to Craft CMS for use in Twig and PHP.
To install Kint, follow these steps:
kint
directory into your craft/plugins
directorygit clone https://github.com/mildlygeeky/craft_kint.git
directly into your craft/plugins
folder. You can then update it with git pull
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.
d
, dd
, s
, sd
, and time
for easier usageBrought to you by Mildly Geeky