When working to debug WordPress projects, I’m personally a fan of using Codebug (something I should probably write about a bit later), but it’s more of a general debugger than one specifically tailored for WordPress.

If you’re looking for the later, then there’s a solid plugin available from Tonya Mork (of Know The Code) that brings the features of Kint Debugger into a WordPress plugin.

For those who have never used a professional-grade debugger, this is a great way to get started with going beyond the standard print_r and var_dump statements that so many often use to locate problems.

Using Kint To Debug WordPress

First, the plugin is based on the Kint Debugger software.

Kint PHP Debugger

You can read more about it on the project homepage, but the gist of the project is as follows:

Kint for PHP is a tool designed to present your debugging data in the absolutely best way possible. Easy to use, but powerful and customizable. An essential addition to your development toolbox.

When you spend a few minutes browsing the documentation, you can see how this can be much more beneficial to your development environment than constantly viewing the standard PHP output.

Even still, this particular project is specific to general PHP development.

Kint Debugger For WordPress

Since the majority of people who read this blog are those who work with WordPress, having a tailored can be much more helpful. And that’s where the plugin comes in handy when looking to debug WordPress.

Debug WordPress with Kint

From the plugin homepage:

Kint is a modern and powerful PHP debugging helper, which requires zero-setup and replaces var_dump(), print_r() and debug_backtrace().

For those who are familiar with wrappers, then you’ll likely recognize that this particular plugin is practically a wrapper for the debugger.

But it helps to bring a little more insight into what’s happening with your WordPress-specific code as opposed to blindly using print_r and var_dump and echo statements.

For example, the plugin not only introduces nicely formatted information but it also introduces functions like:

  • d
  • ddd
  • ~d
  • +d
  • !d
  • -d

All of which are explained in the documentation for the plugin.

Improved Debugging?

Debugging is one of the most important skill a developer can have, thus having a proper debugger should never be understated.

Though there’s no replacement for the tools that PhpStorm, NetBeans, Codebug, or Xdebug offer, I recommend checking out this plugin if you’re looking for a way to improve your debugging skills but aren’t quite ready to invest the time in learning the ropes of a full-featured debugger.

Category:
Resources
Tags:

Join the conversation! 8 Comments

  1. Hi Tom,

    That’s a pretty useful tool. Especially when you are customizing a WordPress poorly coded by someone else.

    In my recent experience, I was stuck at a pie register’s registration filter – I checked all the theme’s code, but could not find a add_action or add_filter function anywhere! After hours of work, I found that the client’s old devleoper edited plugin’s own file instead of writing a filter function.

    I will use this tool to fix such issues in the future.

    Thanks

    • After hours of work, I found that the client’s old devleoper edited plugin’s own file instead of writing a filter function. Depending on the work they were doing, this might have been the best place to put it. I don’t really know without any more information.

      Given that, it sounds like you’d also benefit from checking out this plugin, too.

  2. Hi Tom,

    As a beginner learning WordPress by examing the code in _s, I’m grateful for your post. This plugin may be a very helpful learning tool.

    Scott

  3. Maybe something to finally replace Rarst’s old, but stil useful R_debug class.

    Long ago I started including Rarst’s debug class in my starter core functionality plugin so it was always available. Better would be including Debug Bar, Query Monitor and now Kint via composer. I should look into that…

    Thanks… and I’ve read your past post about Codebug but I’d love to hear more about it. Maybe a more practical tutorial on using it than the 60 sec intro that could address the “when to use it” not just the “how to use it”. Thanks as always!

    • Better would be including Debug Bar, Query Monitor and now Kint via composer. I should look into that… Yes, I dig these and I think they should be part of the whole “debugging package” you can include in WordPress development (though they shouldn’t replace an actual debugger).

      Maybe a more practical tutorial on using it than the 60 sec intro that could address the “when to use it” not just the “how to use it”. That’s a good idea — I’ll see what I can do about putting something together (one of these days :).

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.