Recently I was creating a PHP class to help extract fragments of malformed HTML documents. This small project is a work in progress and while using PHPStorm I wanted a simple means to view a nice view of the output of complex PHP variables. I am used to using Drupal’s Devel module to output code to a webpage, and while I’m familiar with debugging tools in PHPStorm I simply wanted a similar tool for barebones PHP script that wasn’t tied to Drupal.
So I found Kint — A modern powerful PHP debugger. Which is available to Drupal’s Devel module as a submodule; which is why I knew this tool existed outside of the Drupalspehere.
Installing and Using Kint
Installing Kint is as dead simple as extracting it to your projects folder and simply requiring the Kint class file to your script:
require './kint/Kint.class.php';
composer require raveren/kint "dev-master"
After requiring Kint into your project you can then simply call it as needed to debug variable output and stacktraces as need be. I setup PHPStorm to use a local php server to debug my script and simply goto the class I’m working on and view the output from my in-progress code:
As you can see Kint offers a simple, clean useful way to view the state of variables in my code. It also supports mouse and keyboard based navigation if you work that way (which I don’t).
So for me in this small task King was a simple, unobtrusive tool to inject into my budding code to inspect the output of some variables while I debug this script. Yes, PHPStorm can do this too with it’s built-in debugging tools but I’m less comfortable using them at this time.
Looking for quality web hosting? Look no further than Arvixe Web Hosting!