Debugging PHP5 with Eclipse PDT under OSX: a piece of cake!
Posted by Carlo - 12/06/07 at 10:06:57 pmIn 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:
echo $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:
- Eclipse PDT
- Apache (I have found MAMP really interesting)
- XDebug binary compiled for OsX
- XDebug plugins for PDT.
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
—————————————–
[More Help]
15 Comments »
RSS feed for comments on this post. TrackBack URI
Leave a comment
Powered by WordPress with GimpStyle Theme design by Horacio Bella.
Entries and comments feeds.
Valid XHTML and CSS.









FCHouse.com: Debugging PHP5 with Eclipse PDT under OSX: a piece of cake!…
…
Trackback by PHPDeveloper.org — Friday, 15 June 2007 #
[…] 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 […]
Pingback by developercast.com » FCHouse.com: Debugging PHP5 with Eclipse PDT under OSX: a piece of cake! — Friday, 15 June 2007 #
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!
Comment by Sid — Monday, 18 June 2007 #
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
Comment by Carlo — Monday, 18 June 2007 #
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?
Comment by Carlo — Monday, 18 June 2007 #
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
Comment by Beau Scott — Tuesday, 10 July 2007 #
The spam filter has killed some comments!
Sorry to those who wrote here in the past days!!! :(
Comment by Carlo — Thursday, 12 July 2007 #
[…] Debugging PHP5 with Eclipse PDT under Mac OS X […]
Pingback by PHP QA: Recursos para pruebas automatizadas | Ingenieria de Software — Monday, 6 August 2007 #
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.
Comment by Michael — Tuesday, 7 August 2007 #
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!
Comment by Carlo — Tuesday, 7 August 2007 #
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
Comment by xurizaemon — Tuesday, 21 August 2007 #
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 ;)
Comment by Charlie — Wednesday, 19 September 2007 #
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
Comment by Carlo — Thursday, 20 September 2007 #
I have visited your site 409-times
Comment by Visitor696 — Friday, 28 September 2007 #
Hi Visitor696
I hope that in these 409 times you felt comfortable to write your comment!
Have some nice 409 more visits
Carlo
Comment by Carlo — Friday, 28 September 2007 #