Photographing London Photoblogging our life from London!

Debugging PHP5 with Eclipse PDT under OSX: a piece of cake!

In these months I have developed in PHP with Eclipse PDT (Php Development Tool). During the first days I tried to make the debugging works, but without great results, therefore I dropped and I took back the usual debugging technique of every good script developer:

Eclipse PDTecho $variableName;

or simply logging everything possible in some log files. Initially I wasn’t so happy, because every time some result was not what I was expecting I felt myself a little frustrated not being able to understand why in few breakpoints. I have to admit that since then I haven’t thought a lot about debugging, but today my eyes felt on a very interesting post on how to make the debugging works under OSX and PDT, in few steps…

First of all the requirements:

My version of PDT is the latest one (RC3, the latest available as today), therefore I didn’t download the XDebug plugin version 0.1.3 (good for the RC2) as stated in the post, but the version 0.2.1.

For everything else I’ve followed the instruction on the L.ADrupal site! many thanks Guys!!!!!!

PS: here you will find a copy of the post…

———————————–

So, there are three packages you’ll need to get this set up: the Eclipse PDT pre-compiled, the Xdebug plug-in, and the Xdebug.so binary (either PPC or Intel version) that hooks into Apache. Actually, I guess the fourth package, which is kind of a prerequisite, is the latest copy of MAMP, available for download here. Just get the regular, non-pro version.

Get Eclipse with the PHP environment from Zend’s site here.

Now the tricky bit: you’ll have to get a precompiled version of Xdebug.so for your system (you could, of course compile it yourself, but it seemed like in order to do that, one must also compile Apache in tandem, and I find downloading it already built a much less scary prospect ;-) ).

Luckily, the wonderful folks at Activestate have precompiled it for us. Download a demo version of their IDE package for your processor here

Open it up, and drill down to /Applications/Komodo.app/Contents/SharedSupport/php/debugging/5.1/, grab the Xdebug.so file and copy to /Applications/MAMP/Library/share/php/.

Open your MAMP console:
- make sure Apache and MySQL are running on the default ports 80 and 3306
- Disable Zend Optimizer and EAccelerator
- Enable PHP 5

Open /Applications/MAMP/conf/php5/php.ini and insert the following lines:

zend_extension=/Applications/MAMP/Library/share/php/xdebug.so
xdebug.remote_enable=1
xdebug.remote_handler=dbgp
xdebug.remote_mode=req
xdebug.remote_host=127.0.0.1
xdebug.remote_port=9000
xdebug.idekey=your_user_account_name

Re-start MAMP’s Apache, and check phpinfo() to make sure XDebug has been successfully installed.
Get Dave Kelsey’s XDebug for PDT plugin, you’re going to need the “Prebuilt Binary of XDebug V0.1.3 support for PDT RC2 only”.
Copy plug-in files into Eclipse plugin directory

—————————————–

Share and Enjoy:
  • Digg
  • del.icio.us
  • Reddit
  • email
  • Facebook
  • Google Bookmarks
  • LinkedIn
  • Ma.gnolia
  • MySpace
  • Ping.fm
  • Pownce
  • Slashdot
  • StumbleUpon

19 Comments

FCHouse.com: Debugging PHP5 with Eclipse PDT under OSX: a piece of cake!…

Posted by PHPDeveloper.org on 15 June 2007 @ 1pm

[...] Carlo on the FCHouse.com blog, there’s this new guide to debugging your PHP5 application with the Eclipse PDT functionality in an OS X environment. In [...]

Posted by developercast.com » FCHouse.com: Debugging PHP5 with Eclipse PDT under OSX: a piece of cake! on 15 June 2007 @ 5pm

you can download a debugger from zend studios for free…on the same page in which you get PDT.

Click on “Download Debugger Extension Binaries” on http://www.zend.com/pdt

Installation is very simple. Havent tried remote debugging yet..

Is there any reason why I should use XDebug? Cheers!

Posted by Sid on 18 June 2007 @ 7am

Hi Sid!
I did never tried the Zend Debugger, but I will give it a try and I will made a small comparison with the XDebug.
Thanks for the hint and get back to read more!

Cheers!

Carlo

Posted by Carlo on 18 June 2007 @ 8am

Hi Sid!
I admit that I didn’t spend a lot of time trying, but my test were not working with the Zend Debugger…

Can you give me more clue on your configuration?

Posted by Carlo on 18 June 2007 @ 9am

Here’s the wiki post for debugging using Zend Debugger in PDT. (note that the example is on a window machine, but I’m sure you can extrapolate from there…)

http://www.thierryb.net/pdtwiki/index.php?title=Using_PDT_:_Installation_:_Installing_the_Zend_Debugger

Posted by Beau Scott on 10 July 2007 @ 4pm

The spam filter has killed some comments!
Sorry to those who wrote here in the past days!!! :(

Posted by Carlo on 12 July 2007 @ 2pm

[...] Debugging PHP5 with Eclipse PDT under Mac OS X [...]

Posted by PHP QA: Recursos para pruebas automatizadas | Ingenieria de Software on 6 August 2007 @ 5pm

Carlo,
The thierry link provides a detailed description. The key points are you need to disable the XDebug support to use the ZendDebugger.

Use the zend link to download the debugger. I downloaded the 5.2.6 version.

Copy the appropriate ZendDebugger.so to your PHP extensions directory.

Edit php.ini:
– edit output_buffer = 0
– add zend_extension=//ZendDebugger.so
– add zend_debugger.allow_hosts=127.0.0.0/32, 192.999.0.0/16 # supply your own net address
– add zend_debugger.expose_remotely=always

Restart Apache (or whatever web host you are using).

Load an x.php page with phpinfo() in it. (Note, a test page is included with the ZendDebugger archive.) You should see ZendDebuger v#.#.# next to your Zend logo.

Posted by Michael on 7 August 2007 @ 3am

Hi Michael,
I have seen the thierry link, but for now the only way of managing the debugging under OSX has been the one I’ve tested.
I will check the Debugging with the Zend extension instad of the xDebug one, but as long as it works… :P

One thing I have noticed is that you have be VERY careful to use the right version of the xDebug extension with the right version of Eclipse!

Thanks, however, for the tip!

Posted by Carlo on 7 August 2007 @ 6am

save some download, and farting around with the activestate download registration (which doesn’t work for me)

get the PHP remote debugging tarball from here: http://aspn.activestate.com/ASPN/Downloads/Komodo/RemoteDebugging

cheerio

Posted by xurizaemon on 21 August 2007 @ 2am

Hi all,

I don’t get it. What is this about Komodo en Eclipse? I guess this is compatible and Eclipse looks for the Komodo folder?
I read it one more time ;)

Posted by Charlie on 19 September 2007 @ 6pm

Hi Charlie,
you need to obtain the debugging extensions. Those bundled with Komodo works perfectly, so you should download them.
As xurizaemon kindly post, you can find them here:
http://aspn.activestate.com/ASPN/Downloads/Komodo/RemoteDebugging

Everything is about Eclipse, but you just need the Komodo debugging extension.

Cheers

Carlo

Posted by Carlo on 20 September 2007 @ 9am

I have visited your site 409-times

Posted by Visitor696 on 28 September 2007 @ 10am

Hi Visitor696
I hope that in these 409 times you felt comfortable to write your comment!

Have some nice 409 more visits

Carlo

Posted by Carlo on 28 September 2007 @ 11am

Thanks for this article Carlo, Was really useful.
An important remark: When you are getting the Xdebug.so binary, be sure you are taking the correct version for your PHP version.
Lets say: If you are running PHP 5.2.x you must take “…/debugging/5.2/Xdebug.so”
Regards!

Posted by Lisandro Grassini on 8 March 2009 @ 1pm

[...] Go here to see the original: Debugging PHP5 with Eclipse PDT under OSX: a piece of cake! | Photographing London [...]

Posted by Debugging PHP5 with Eclipse PDT under OSX: a piece of cake! | Photographing London on 27 April 2009 @ 5pm

Good post! I researched this several month ago. At that time I used MAMP Pro and run into many problems which let me to set up my Mac dev environs with Entropy PHP, mySQL, Eclipse and XDebug. If anybody is interested in that info you can read about it here: http://www.theglinkacompany.com/blog

Posted by werner glinka on 16 July 2009 @ 7pm

[...] találnom egy megoldást (több helyen kifejtve az interneten Setting up Eclipse PDT and XDebug Debugging PHP5 with Eclipse PDT under OSX: a piece of cake!), az Eclipse rendszer megfelel? [...]

Posted by PHP debug Eclipse PDT-ben « GhoUl on 22 August 2009 @ 1pm

Leave a Comment