Bug-Free: Using Function Traces To Better Understand Code (Part 3 of N)

Have you ever been handed some code and told, “make it work”? If you haven’t, chances are good you will some day. It’s often a daunting task, especially since, as one programmer told me, “comments come when the second developer has to make changes.” While this is likely bad coding practice, it’s happened to me more than once.

Lucky for us, XDebug has a built-in tool that helps us evaluate code and figure out some of what is going on without spending all week reading the documentation or the code itself. It’s called “function profiling.”
Continue reading

Bug-Free: Using XDebug To Improve Development (Part 2 of N)

There are two really great experiences in my PHP life: the day I learned how to use PHP, and the day I installed XDebug. Ok, perhaps that’s an overstatement, but XDebug is one of the best tools I’ve ever used. I think every developer should use it, and for the next part of this series we’re going to talk about its features.

XDebug allows you to do a number of things: first, it provides styling to your stack traces and stack traces every error. Second, it allows for profiling. Third, it provides some variable output tools that are just necessary when working with PHP.

XDebug is an extension for PHP, and before you do anything you should probably download and install it from the XDebug website. Don’t worry…I’ll wait…
Continue reading

Bug-Free: Your Bug-Fixing Toolkit (Part 1 of N)

PHP has a large number of tools for fixing bugs and resolving underlying issues. But many people don’t know what they are, and some of them are extensions requiring installation in order to work. In this series, we’ll explore some features for debugging PHP scripts, from the most basic to more advanced.

Today we will discuss tools that ought to be in your bug-fixing toolkit already. There are three tools that everyone should already have:

  • var_dump();
  • print_r();
  • var_export();

Continue reading