An Introduction to Debugging for WordPress Developers

In the most recent post in this series, I walked through the process of integrating Xdebug with your IDE. And given that I’ve been using Visual Studio Code as my IDE of choice, that’s also the IDE I’m using as the example.

Installing Xdebug: PHP Debug for Visual Studio Code

Furthermore, it’s cross-platform, easy enough to get started for beginners, but powerful enough to extend and operate for more experienced programmers (and for the rest of us who fall in between).

In the last post, I stated that I’d be doing a series of screencasts. Specifically, I wrote the following:

Starting in the next post, I’ll begin sharing some screencasts that walk through how to debug functions and variables, change values on the fly, work with the debug console, and more.

In this post, I’m going to have a short screencast providing an introduction to debugging WordPress the first part of this series. Namely, launching an instance of a site built using WordPress and using the basics of debugging a plugin.

Read More

Installing Xdebug, Part 2: The IDE

Now that Xdebug is installed with your local installation of PHP, it’s time to wire it up to the IDE. This provides us with all of the advantages that Xdebug has to offer.

Installing Xdebug

That is, it allows us to:

  • set breakpoints,
  • step through our code,
  • and watch variables

All the while the program is executing. This means that while is a page is rendering, we’re able to set points in our codebase where we can see what the server is doing with our code.

So, sure, even though it’s called debugging to remove bugs, it can also give insight on how a WordPress-based application, theme, or plugin is executing and can help us gain a better understanding of WordPress core.

Read More

Installing Xdebug, Part 1: The Xdebug Module

By now, we’ve covered a lot of ground as it relates to working with WordPress and debugging. And this is especially true as it relates to working with tools and plugins available within WordPress. If you’re just joining this particular series, please make sure you’re caught up with the following posts:

In the previous post, recall that I said the following:

But if you’re looking to get into the world of professional, practical debugging from within your IDE, then it’s important to understand the what, how, and why.

And we’re finally ready to look at what this requires. To get started, however, means that we need to understand a few things about Xdebug, the terminology, and to have an IDE that’s consistent for everyone reading this particular series.

Installing Xdebug

So this is going to be broken into two parts.

  • First, we’re going to look at the terminology required for debugging and make sure that we have a proper IDE setup in our development environment,
  • Next, we’re going to look at how to ensure we’ve properly installed Xdebug and then wiring it up to our development environment so we can put it to work.

If you’ve read a variety of content throughout this blog over the past few years, some of this may seem familiar. If not, no big deal. Remember the goal is make sure we’re all on the same level as we proceed forward with the work mentioned above and throughout the rest of the series.

With that said, let’s get started.

Read More

Basic Debugging Within WordPress

As we continue to head towards working with direct debugging with Xdebug, we have a few tools at our disposal that allow us to work within WordPress itself. These aren’t meant to be replacements for any other debugging tool, but compliments to them.

I began by discussing this in the previous part of the last series. Specifically, I wrote:

Now though, we need to turn our attention to the plugins that were discussed a few posts ago. After that, we’ll eventually be working our way up to Xdebug.

But next, we’ll look at the tools available to us from within WordPress itself.

Ultimately, the goal is to look at what’s available for us to use to find problems, test code snippets, and profile our work. And several plugins make this incredibly easy (and are quite powerful) as it relates to doing just that.

Read More

Reading and Understanding WordPress Error Logs, Part 2

Last time, we walked through the following:

  1. configuring debug constants,
  2. locating an error log file,
  3. understanding how to read the log file,
  4. understanding stack traces
  5. understanding how to read the stack

As nice as that is, it’s still important to understand how to write data to error log from a programmatic aspect. That is to say; it’s one thing if your work throws errors, warnings, or notices.

Understanding WordPress Error Logs

It’s another thing if you want to understand how to write information to the file for research and debugging manually.

In this post, we’ll continue doing exactly that to further our understanding WordPress error logs.

For Members Only

Thanks for your interest in this article; however, it's available to members only. If you'd like to review this (and have access to all previous and future articles), check out the sign-up page.

Read More