Confession time. I don't use an IDE (Integrated Development Enviroment) for Drupal development. Sometimes, I kind of wish I did because having all of the development tools in one place is great; but all of the IDEs I've tried for my platform (I'm a OS X user) try to change the way I work, lack key PHP features, or are incredibly slow. And I really like TextMate. Thankfully I've found a great PHP debugger for OS X called MacGDBp and, at least for me, the chances of switching to an IDE continue to dwindle.
MacGDBp requires the xdebug PHP extension, which is useful to have even if you don't use a debugger, since it provides pretty stack traces and other tools. If you use Macports, you can install xdebug by typing sudo port install xdebug at the terminal. Otherwise, Komodo has a packaged version of the extension, and the MacGDBp site gives full setup details. One xdebug is installed, you can install MacGBBp just like a normal OS X application.
Now onto debugging, finally! Fire up MacGDBp and you'll be presented with two windows: a debugger and a list of breakpoints. The first thing to do is set breakpoints. Hit the "+" button at the bottom of the breakpoint window to choose the file you want to add the breakpoint to. The file will open up at the top of the window, and you can click on a line to add a breakpoint to that line, and all the breakpoints are saved when you close MacGDBp. While you can add a breakpoints by calling xdebug_break(); in your code, it is frighteningly easy to forget to remove those lines before shipping, so I wouldn't recommend it. The MacGDBp breakpoint window:
To run the debugger, click the power button in the main debugger window. The debugger will attempt to make a connection to xdebug, but unless you happen to be in the middle of a page load, nothing spectacular will happen. Try loading a URL that will call your breakpointed code. You won't get a response from the browser, because PHP will be waiting for a response from the debugger. At this point, the "play" button in MacGDBp should work and allow you to step through the code as you would for a normal debugger. Press it once to start running through the code. It'll stop when it hits the first breakpoint, and give you a stack trace and variable list at that point in the code. Like most debuggers, you can then choose to step over the breakpoint line to the next line of code, step into the breakpointed line, or continue executing until the next breakpoint. You can add or remove breakpoints at any time, from either window. Here's a screen shot of the main debugger window with variables, stack trace, and code context:
While it would be convenient to connect MacGDBp to a development server, I haven't yet figured out whether it's possible to get xdebug to make the connection through the security. On the whole I'm pretty happy with the light-weight graphical interface, the uncomplicated window into my code, and standard methods of debugging. I've found that MacGDBp does exactly what I need it too, and despite not working with the development server (and the terrible name!) it means I can stick with the tools I'm comfortable with for other aspects of development, and that's a good thing for my sanity and my code.