By Troels Knak-Nielsen

Debugging PHP

By Troels Knak-Nielsen

I just checked in a little project, I’ve been working on for the last couple of weeks.

It really begun at the last Copenhagen php-meetup; Joakim Nygård and Jacob Oettinger made a presentation of their project, WebCacheGrind. I casually mentioned something about having played with the dbgp-protocol (The debugging part of Xdebug) and that it ought to be simple enough to write a fontend for it. That prompted some snickering from the back row. Apparently some guys had this rule at their workingplace, that whomever said that something ought to be easy to do, had to do so himself. Not an unreasonable rule, I suppose. Obviously, I couldn’t let that go unattended, so I gave it a shot.

Screenshot of Spectator

Spectator is a XUL application, which should make it cross platform. I have tinkered a bit with XUL before, but not a full application. If you’re wondering what XUL is, it’s the GUI toolkit, in which the frontends for Firefox and Thunderbird are written. It’s a markup language — much like HTML, which can be scripted with Javascript. This makes it very easy to work with. The only problem seems to be a rather lacking documentation, but a bit of detective work got me through that.

So what can spectator do? Mind that this is a first version and I really just meant it as a proof of concept. I think I got a bit further than that, but it probably still has a few bugs. Still, with the current version, you can step through a program, set breakpoints and inspect the stack. Really all you would expect from a debugger.

Of course, as some of you might point out, there are already other implementations available. Most notably Komodo, which is also implemented with XUL. However, these implementations are proprietary, and are integrated with an IDE, that you may not want to use. Spectator is an open source alternative and is IDE/editor agnostic.

  • Lukas

    You do know that Komodo is going “open source” for their next major upgrade:

    Not that it deminises the usefulness of a KISS xdebug frontend in XUL at all. But something to aware of ..

  • Chris

    Great work. I’ve been looking for a no-nonsense cross platform app to debug my php code on. Just to let you know I have also run it successully on Windows using the XULRunner that is part of Firefox 3:

    firefox.exe -app pathtospectatorxulapplication.ini


  • asbjornu

    Looks interesting! Since it’s based on XUL, perhaps it can be integrated with Open Komodo which is an open source text editor / IDE also based on XUL?

  • Tobias

    Works like a charm on Mac OS X (10.5.3). Looks as ugly as an XUL app, but works really great! Fantastic work!

  • kyberfabrikken

    Since it’s based on XUL, perhaps it can be integrated with Open Komodo which is an open source text editor / IDE also based on XUL?

    Yes, I suppose it could. The model layer libraries are independent of the presentation layer, so you could reuse these in Komodo. I don’t have much incentive for doing so though, since I prefer to use a stand-alone editor (Mostly Emacs). There are obviously some benefit to have editor and debugger integrated, but I don’t think it’s much of a problem to have the two running separately.

  • Mikkel Høgh

    Hey, that’s awesome – I’m surprised you followed through, since that rule only really applies to employees ;)

  • Jani

    Why not make this a Firebug extension..? :)

  • MrMenu

    We are running a geo-spatial query for the restaurant takeout and delivery zone feature on our site and have had some problems debugging it. The issue came while incorporating it into the rest of our .php design. I will try this out. Thanks!

    Oh, and if you are looking to order takeout or delivery food online and live in the Phoenix area, check out our Top Rated Restaurants.

Get the latest in Front-end, once a week, for free.