Goodbye var_dump, Code Stepping with XDebug and PHPStorm

Several weeks back I had my world turned upside down when I took the advice of Luke Woodward, my team’s Senior Web Engineer at 10up, to hook up code stepping with Xdebug to help troubleshoot a problem I was working on. Boy was that a good idea! I had been intending to hook this up for a while but had never made it a priority, but now I use it every day as a replacement for conventional debugging tools like ‘var_dump()’ and ‘wp_die()’.

Code Stepping Requirements

Let’s step back a few paces for a moment though. There are a few requirements for setting up code stepping:

  1. A developing environment equipped with Xdebug (if you use Varying Vagrant Vagrants then you are all set)
  2. An IDE such as PHPStorm or Netbeans (I use PHPStorm)



You may not know what Xdebug is (I use it every day and I can hardly explain it). “Xdebug is a PHP extension which provides debugging and profiling capabilities.” (Thank you Wikipedia.) Practically, if you have Xdebug setup on your environment you may get error or debug output like the image above. The benefit, as you can see, is that Xdebug will provide you with a trace of the error or debugging output to help track down an issue.

This alone is reason enough to use Xdebug in your developing environment. But once you see code stepping in action, you will feel handicapped without it.


An IDE (Integrated Developer Environment) is a necessary component to code stepping. With an IDE, we will establish a connection to our development environment, set breakpoints in the code, and then listen to the server via Xdebug for the specified breakpoint.

If you do not have an IDE, I would highly recommend finding one that you like. Not only will an IDE support advanced debugging like code stepping, but you can also set it up to automatically factor your code according to WordPress standards, click into functions, enable function auto-complete, and the list goes on. This post is not about IDEs, though, so I will stop there. 🙂

Setting Up Code Stepping

Once you have Xdebug on your local environment and are using an IDE for development, you will be very surprised at how easy setting up code stepping really is. It took me all of an hour to set up and 45 minutes of that was because of a typo.

Instead of writing out step by step instructions, I am going to leave you with this excellent walk through put together by my good friend Taylor Dewey. This will take you through setting up code stepping with Varying Vagrant Vagrants and PHPStorm. Stay tuned ’til the end to see a live demo of code stepping. Whether you have VVV and PHPStorm or not, the principles aught to carry over. If you find any helpful tips please feel free to comment below.

Leave a Reply