Debugging PHP with free tools (PDT + XDebug2)
One very important part of an IDE is the ability to debug the code you write. For web-application development you mostly need remote-debugging facilities. It’s no problem to find a good IDE offering all that for Java web-development. There’s Eclipse and it provides all sorts of features that make a developer’s life easier. For PHP development it’s much harder to find a free IDE that provides good (remote-)debugging features. There’s Zend Studio and Komodo but both aren’t free software. You get Zend Studio for about 350 EUR (~480 USD) and Komodo for 295 USD. For students Zend Studio is 25% cheaper and Komodo is 49 USD. Not free at all, isn’t it?
Approx. one year ago I tried to get a remote-debugging environment using PHPEclipse together with DBG. That was a PITA to set up and once it worked it was just awfully unstable. I figured out that the PHPEclipse people were developing a plugin to use XDebug but there didn’t seem to be much progress. So I stopped my efforts on free remote-debugging.
Some weeks ago XDebug2 was released and I decided to give the remote-debugging thing one more shot. I tried PDT + XDebug2 and guess what – it worked out fine!
First of all you need a PHP installation with XDebug2. If you don’t have it installed yet (shame on you
), you can find instructions here. Your next step should be getting PDT. I tried the latest integration build. Additionally you need some plugins for XDebug-support that are only available from the PDT bugzilla:
- Prebuilt Binary of XDebug Support for V0.2.3 for PDT 1.0 I20070712
- Example Mapper V0.0.2 for XDebug 0.2.3
Once you have all that installed you can create a PHP-project in your PDT-eclipse and configure the environment (XDebug2 and PDT) for debugging. Daniel Holmström published a really good guide on how to install and set up everything in detail. If you follow his instructions you should have everything up and running within half an hour. After that you will be able to enjoy local- and remote-debugging of your PHP-scripts.

All in one package is available at:
http://www.zend.com/pdt
this package includes Zend debugger rather than XDebug as you mention in your article.
I published an article on how to setup
- Java version 6 update 1
- Eclipse 3.2.2 Build id: M20070212-1330
- PHPEclipse 1.1.9 CVS
- DBG 2.15.5
- SVN plugin Subclipse 1.2.2
http://noteplog.com/how-to-install-a-cool-php-development-environment-on-linux/
I followed the settings (Apache 2 here), and get this error in Eclipse whenever I try to debug a remote script:
Incompatible Debug Server Version
Probably the remote debugger protocol does not match the expected protocol version (2006040701)
Doron, it’s hard to say what’s wrong with your setup. Maybe this one helps you: http://dev.eclipse.org/newslists/news.eclipse.tools.php/msg01327.html
Or this (same solution but less text to read): http://www.sagewire.org/php-tools-eclipse/XDebug-support-incompatible-version-372118.aspx
I’ve been using PDT + Xdebug but when locally debugging files I have yet been able to figure out how to pass POST values. Other than typing them in at the top of the file being debugged, is there anyway I can pass POST variables to the eclipse debugger??
[quote] For PHP development it’s much harder to find a free IDE that provides good (remote-)debugging features. [/quote]
http://www.php-debuggers.net
Hopefully it will be a one-stop resource for debugging PHP applications. Please take a quick look
It seems that the Xdebug support plugins from bugzilla are broken in Eclipse 3.3.
When I try to create a new remote debugging configuration it throws an error in org.eclipse.php.internal.core.util.FileUtils.FileExists(). (Looks like the same exception in MacOS 10.4, 10.5, & XP.)
The Zend debugger plugin for Eclipse claims support for Xdebug, doesn’t puke, and looks like it is trying to start a debug session, but FWICT it never attempts to connect to the server on port 9000.
I want this to work badly enough that I might consider turning back to an older Eclipse. What version has anyone had success with?
Anderson, you should try the latest PDT all-in-one build: http://download.eclipse.org/tools/pdt/downloads/release.php?release=R20080103
Right-o. I followed a lot of blog-trails, the eclipse.tools.pdt newsgroup, and finally had the sense to RTFM (XDebug.org)–eventually got all the pieces working awesomely.
A few things I learned that were not obvious to me at first:
- no longer need the XDebug-Support plugin mentioned in original post. It doesn’t work in Eclipse 3.3. Just get the PDT, as suggested.
- the path mapping in PDTs “PHP Web Page” debug configuration are the filesystem paths of source files on server and client, NOT apache “locations”.
- the XDebug server connects _out_ to the client, opposite of java JDPA. That was not obvious from blog howto’s that I read, and debugging worked fine for localhost, so I didn’t realize I had it backward until I finally read the real XDebug docs.
I’ve recently switched from asp.net to php, since it’s free, poweful and easy. I picked it up really quickly.
But, without a good debugger, no matter how good you are, you’ll be a lot less productive. And I could not set up a debugger for php yet… it’s frustrating.
It reminds me of the same reason why people doesn’t use linux, its just not practical. If you have to go through this kind of issues just to set up a basic tool like a debugger…
I just published a detailed step by step guide on how to get PDT + XDebug up and running, see here:
http://robsnotebook.com/php_debugger_pdt_xdebug