If you program at all, you understand the necessity of debugging. Fortunately, depending on the language in which you program, you can find an assortment of tools to help you with this task. One very good debugging tool for PHP is the X-debug extension. This seven-part series will reveal its capabilities and help you add it to your programmer's toolbox.
Without a doubt, debugging is one of the most important tasks that programmers have to tackle when developing both desktop and web-based applications. With PHP, this process can be accomplished more quickly because it’s an interpreted language.
Even so, PHP itself contains a few simple mechanisms that permit you to debug programs at a basic level. For instance, by enabling the “error_reporting” and “display_errors” directives included within its php.ini file, and also by combining “echo” statements along with the popular “var_dump()” function, it’s possible to debug runtime errors with relative ease.
However, there are certain situations that require a more sophisticated debugging process. In cases like these, it’s often necessary to verify other aspects of an application, aside from checking to see if a function is called in the correct sequence, or if a class actually produces the expected output.
On these specific occasions, the ability to evaluate the status of certain variables, measure the time that a script takes to run, and even determine how and when a given class calls its different methods is a must. Naturally, the simplest way to perform a debugging process as detailed as this is to use a third-party library, which can be picked up from the great variety available nowadays.
Even though there are plenty of debugging libraries that can be used in a pretty straightforward fashion with excellent results, there is one useful extension, called “X-debug” (http://x-debug.org) that combines good functionality, an easy learning curve and minimal installation requisites.
So, in this series of articles I’ll be providing you with a brief overview of the main features that come bundled with the X-debug extension, so you can start using it quickly for debugging your own PHP applications with minor hassles.
Now, with the preliminaries out of our way, it’s time to begin exploring the real capabilities of the X-debug package. Let’s jump in!