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:
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
—————————————–
19 Comments