The pain of PHP debugging

You would have thought by now that I am up and running with a good PHP development environment and coding away furiously. Nothing could be further from the truth. I got stuck on debugging PHP. The main problem is this: I am too thrifty (some would say cheap) to invest in a proper PHP IDE. Instead, I have spent much time looking around for open source alternatives, or failing that, anything that is free.

I don’t think I have downloaded everything that is out there, but I can guarantee you, I have downloaded most. I have tried several trial versions of commercial IDEs. I can’t believe how many PHP Editors/IDEs there are, and as I keep looking, it seems I find more of them. The one thing that a good commercial IDE has, of course, is debugging support. Preferably something that starts its own local web server where debugging is already enabled, and saves you the time and hassle of setting it up yourself. That’s not worth n amount of dollars to me, though.

Instead, I have embarked on a mission to get the debugging working through many hours of toil. I have tried both PHPEclipse and PDT. Both have their drawbacks: PHPEclipse does not seem to be very actively maintained (anymore, at least), while PDT is still very immature. I got DBG debugging working with PHPEclipse, but for some reason, when up and running, the client ate up all of my CPU power. I wasn’t interested in finding out why, so I moved on.

I have now settled on a solution that I think will work for me in the long run: I don’t need to have debugging integrated into my IDE. I will use a standalone debugger. I can (and think I just might) use the freely available (see how your ears prick up when you hear those words?) Expert Debugger. It is a (and I repeat) freely available DBG client, and it does the trick. Quite nicely, actually.

There are of course alternatives to DBG, like XDEBUG, GUBED and APD (whose site I have been unable to reach the last few days, signalling either its demise, or that scores of people are frantically trying to get on to the site; either way, I cannot say anything about it).

Of these, GUBED (which you may have guessed at first glance is “debug” spelt backwards), is an interesting concept. It requires no modification to your web server. Instead, it consists of a number of PHP scripts that you install on your server, and with which you start a debugging session and then launch into the scripts. A debug client is also provided, so it has everything you need in one package. GUBED is on version 0.2, but for its sake (and mine, chiefly), I hope it makes it to 1.0. I have yet to report on its success, as it keeps crashing on startup of the debugging, but I am determined to get it working.

The only thing with the DBG-based Expert Debugger is that I have had to make changes to the Apache config to enable and disable DBG. This I have now solved by creating a virtual host, in which I point to a different location of php.ini where I can enable DBG, and leave my primary host untouched.

You see, not spending money on things merely to make your life easy is a good thing! In the process, you learn a lot.

Having decided to separate my concerns for a PHP Editor, in which I can code (hopefully not just PHP, but HTML, CSS, Javascript, etc.), and a PHP debugger, leaves me free to choose any PHP editor I wish. I hope Aptana includes PHP support soon, although I think that you may be able to integrate the plugin with PDT on the same Eclipse installation. If I get it working and it’s interesting, I will let you know.

Tags: ,

  • Hey Martin,

    I switched from PHPEclipse to the PDT about 4 or 5 months ago for precisely this reason. Getting the debugging is still not ‘a snap’, but it can be done.
    I still find myself writing print_r($array) and echo $sql but that is just out of habit.

  • De Wildt

    Hi Martin,

    I found myself in the same dilemma when I was using PHP and it lead me to were I am now using ASP.NET. It is unfortunate that the open source solution has been replaced but sometimes you have to just get the job done (and battling with debugging doesn’t help).

    The even bigger dilemma is the costs, because not only do you need to buy visual studio (well actually there is an open source IDE that is pretty good but you also have to pay more (in most cases double) for web hosting that supports it.

    So were down to limited/no debugging or shelling out loads of cash for a past time :).

    De Wildt

  • Helmut

    I’ve had problems with debugging support in free/open source software too, but more in the world of .NET. SharpDevelop 1.0 had no debugging support, but version 2.0 changed that a bit. But then I discovered Visual Studio 2005. And it does what I need perfectly. Even beyond that. I discover a cool feature almost every other day. And the best is this is all included in the free version of the IDE, the Express Edition.

    Development is a breeze…

    I’m not as well versed with PHP IDEs, but I hope your current solution brings you what you need without much more hassles!

  • I actually never use debugger on PHP, instead I do it the Java way – glassbox testing.