So, Corey and I hit a lurker of a bug while working on version 2 of mixtapecollective. For some reason, the pages were loading twice -- but only under certain conditions. We rolled back to an older version of the code and found that the bug was introduced sometime in the last couple months, but we couldn't track it down -- there's been a lot of new code. We hacked away for a few hours before realizing that our current setup was pretty janky (see also: tortoise SVN, FileZilla, Notepad++). Stumped, I finally bit the bullet and decided to get Eclipse, my most favourite IDE, installed and set up for locally debugging (and developing!) our PHP project on my little Windows box.

Setting it up sounds simple enough, but I think I hit just about every stumbling block possible. After scouring bug reports, forums and outdated guides, I decided I'd gather my experiences and throw up a quick how-to guide. Here we go:

Step 1:
Ensure that you have JDK 5 installed. I had a newer version installed, but it caused some issues when it came to line-by-line debugging. Save yourself some time and install this bitch first.

Step 2:
Download and install XAMPP. I've used XAMPP for a few versions and it's been nothing short of perfect. It'll set up a local install of Apache (with PHP extensions), a MySql server and some other nifty things. Really slick. My only advice is to install directly to your c:\xampp directory -- I had issues redefining Apache's docroot when I had spaces in the path name (ie: c:\program files\xampp\...). Once installed, verify your docroot is correct (xamppDir/apache/conf).

Step 3:
Download PDT (PHP Development Tools) v07RC2 from http://europa-mirror1.eclipse.org/tools/pdt/downloads/?release=S20070130-RC2. PDT is a version of Eclipse with some really wonderful modifications geared towards PHP development. Documentation is kind of hard to find, but it's still radical. There is a newer version, but RC2 seemed to work out best for me. Install this wherever you wish.

Step 4:
Download XDebug from http://xdebug.org/link.php?url=xdebug200-522-win. Ensure you grab the version designed for your version of PHP. Copy this to the XAMPPDIR/php/extensions file. Determine which version of php.ini xampp is using (it installs a couple, but only uses one) by throwing up a quick phpinfo(). Once found, comment out the zend_extention_ts line under the [Zend] heading and add the following:

[xdebug]
xdebug.remote_enable=1
xdebug.remote_host="localhost"
xdebug.remote_port=9000
xdebug.remote_handler="dbgp"
zend_extension_ts="C:\XAMPPPATH\php\extensions\php_xdebug-2.0.0-5.2.2.dll"


Once that is done, restart Apache and phpinfo() verify that XDebug was loaded.

Step 5:
Download D Kelsey's XDebug for PDT plugin (prebuilt binary / version 0.1.3) at https://bugs.eclipse.org/bugs/attachment.cgi?id=58341. Extract these files to the Eclipse plugin directory. There is an included PDF that is a pretty good resource.

Step 6:
Fire up Eclipse and define your workspace as being your XAMPP htdoc root. If the path to the file that your server is serving isn't exactly the same as the one that Eclipse is looking at, there can be some issues with breakpoints. Just do it!

Step 7 (optional):
Install Subclipse from http://subclipse.tigris.org/install.html. You are using version control, right?

Step 8:
Now, this is where our paths might diverge -- it's pretty dependent on your project. Once you have your project set up in Eclipse, select run>debug and double-click on 'PHP Web Script with XDebug' to set up a new debugger. My settings were as follows:

Script and Server: mtc/index.php
Server URL: http://localhost
Context Root: mtc
URL should look like: http://localhost/mtc/index.php

Step 9:
For me, the outline view / PHP project outline pane didn't work -- i fixed this by opening the .project file in my workarea and replaced the buildSpec and natures nodes. Props to http://cakebaker.42dh.com/2006/12/27/migration-from-phpeclipse-to-php-ide/ for the help.

Now, you should be set up. Set a few breakpoints, fire up the debugger and develop to your heart's content. Hell yes. Hope this helps.

Setting up Eclipse for local PHP debugging

eric

Sunday 22 July 2007 at 1:08 pm

Two comments

Showoff.
JonK
Sunday 22 July 2007 at 1:08 pm
Not a showoff -- this took me a long time to figure out. You should try it, dude. PDT is a savage PHP tool. Not flawless, by any means, but still, beats the shit out of Notepad++.
//eff
Sunday 22 July 2007 at 1:08 pm

Comments

(optional field)
(optional field)
ARE YOU HUMAN?
Remember personal info?
Small print: All html tags except <b> and <i> will be removed from your comment. You can make links by just typing the url or mail-address.

Leave a Message