Debugging PHP on Ubuntu Feisty Fawn

I've recently come through a downright purgatorial effort to get some sort of IDE debugger set up for my Drupal work. Hopefully the notes below will help other folks from running into some of these same problems.


My usual work environment is a Thinkpad T60 running Ubuntu. My work lately has been heavy on the sysadmin work and light on the coding, but I am now setting about finishing our much-delayed CiviLingua contribution to CiviCRM, and was interested in using a more professional debugging tool than (much as I love it) ... var_dump().

Version problems

Upgrading to Feisty Fawn proved deeply problematic in terms of getting debugging to work. Feisty offers nicely current versions of tools such as PHP (5.2.1) and Eclipse (3.2.2). Unfortunately, most of the debugging applications out there are tightly tied to specific, older versions of these tools, so for once, having decently up-to-date software causes more problems than it solves. Some examples:

  • the stable version of PHPEclipse apparently only works with Eclipse 3.1.2
  • the free version of DBG requires PHP <= 5.1 (as of yesterday -- now they're up to 5.2)
  • the Zend debugger binaries are for PHP <= 5.1
  • and so on

Which debugger?

The choices of debugger include Zend debugger, DBG, Xdebug, and Gubed. Many of them are tied to particular IDE/Editor solutions. Some examples:

  • PDT stable only supports Zend
  • PHPEclipse stable only supports DBG
  • Komodo only works with Xdebug

Installing various debuggers has been easy-peasy in my experience. Over the course of this little journey I used all of Zend, Xdebug, and DBG with reasonable ease. Well, I've actually used DBG in the past with reasonable ease, as the free 2.x version it doesn't support either version of PHP I have available locally (my file server runs Debian testing with PHP 5.2.0). [Redaction: it looks like dbg binaries are available for PHP 5.2 now.] Zend and Xdebug install exactly as advertised, however (make sure you get the Zend Debugger on its own, however ... you needn't mess about with the Zend Platform if you don't want all its features and price tag).

Gubed promises to be slow and memory intensive ... which means it's not perhaps a great choice for a heavyweight app like Drupal + CiviCRM. It would be excellent, however, for folks without the experience or ability to modify Apache and PHP configs.

My preference was for Xdebug: it's thoroughly free, unlike the Zend and DBG products (the free version of DBG is a major version behind their proprietary version), and has a good reputation. It was also easy to install and, wonder of wonders, has good documentation.

Which IDE?

IBM has some excellent documents about Drupal development, and an overview of seven different PHP IDEs that were both informative. How fortunate for my decision-making that most of the IDEs they mention are Windows-only, leaving only Zend, Eclipse and Komodo in the running. I've played with an evaluation copy of Zend in the past and didn't love it, so I looked into the tools I had yet to try ...


I tried to make Eclipse work, I really did. I like the idea of a genuinely free IDE that's extensible and flexible, etc., etc. But again and again I installed it, only to have it spew errors left and right.

First I tried installing it with apt-get and using the "Software Updater" to add one or another of the PHP plugin projects. No go. I tried installing PDT from both the PDT repository and Zend. Neither would work for me. Oh, and this happened both with the too-new 3.2 version of Eclipse and the 3.1.2 version.

So, as others seem to have had similar luck, I removed my vanilla installs of Eclipse and downloaded all the "all in one" tarballs -- the PDT and Zend offerings of PDT and the PHPEclipse version, carefully expunging all traces of previous versions of Eclipse from my system each time. All efforts ended in ignominous failure, with obscure Java errors about missing UI elements and invalid form data.

The one time it looked like things were going to work (With Eclipse 3.1.2 and PDT 0.7), Eclipse choked on being asked to import my 28MB CiviCRM code tree. Not much makes my beloved laptop slow noticably, but Amarok was stuttering and skipping like crazy while Eclipse tried and failed to import the files. It failed so thouroughly that the import task survived shutting down Eclipse itself, and I killed it from the command line.

If I ever have any of that "free time" I hear so much about, I'll take another look at Eclipse. Maybe once the PDT project hits its 1.0 release in September.


Downloading and installing Komodo is a piece of cake. It looks slicker and faster than Eclipse in my brief experience with it ... brief because for remote debugging (which is what's required when you debug a web page as opposed to a standalone PHP application) it just acts as an editor with a debugging client built in. And heck, there are lots of those that don't cost $300US.

PHP Editors

I've used the dbg-cli command-line client in the past. It's robust and works and all that, but it's a whole lot more convenient to use something like an IDE or an editor that combines PHP syntax highlighting, etc. with debugger client functions.

Googling for "debugging PHP" leads to a bunch of such options. Quanta Plus is popular (this approach, using Gubed, looks promising), although I discounted it after a little experimentation because I've never really liked its interface for programming.

Xdebug + Protoeditor

This Xdebug web page led me to ProtoEditor, which is an exceedingly lightweight programming and debugging tool built on top of Kate and that -- wait for it -- supports *all* the aforementioned server-side debuggers. (It also has syntax highlighting for PHP, Python, and Perl.) Most importantly, it "just worked".

It's possible to debug a local script or a web app from within Protoeditor, but it also acts as an editor-slash-debugger for web pages viewed in your browser. Thus: enable "JIT" (just intime) debugging in protoeditor; open protoeditor and firefox; load the application in firefox; trigger debugging by appending ?XDEBUG_SESSION_START=<identifier> to the URL. Protoeditor will open each script as it's included and executed, allowing you to step through the code, watch variables, set break points, display global and local variables, and so on.

Plenty of debugging power from a nimble, free program that performs as advertised.

And note that there's a Firefox plugin that lets you turn on and off Xdebug sessions using an icon on the status bar. Very nice. Oh wait, it doesn't work in the new Firefox Gaaaah!




Add new comment

This question is for testing whether you are a human visitor and to prevent automated spam submissions.