by kyleabaker | September 17, 2012 11:25 pm
This guide walks you through the necessary steps to configure the Eclipse IDE for PHP debugging. This can be very handy, especially when you’re trying to resolve an issue in a complex PHP application or plug-in.
Things you’ll need
For those that are unaware, Eclipse is a very popular IDE for developing in Java. However, Eclipse is much more powerful than that and can in fact easily be used for developing in many other languages including PHP.
Xdebug is a brilliant debugging extension designed for use with PHP. Once configured, Xdebug will allow you to remotely connect to your web server… or in my case connect to my development localhost web server. Rather than using crude echo and logging techniques to debug your PHP code, Xdebug allows you to literally step through and inspect values and function flows in real-time.
If you’ve ever scratched your head at a PHP script and thrown in dozens of echos or logging statements to track the execution path then you’ll really come to appreciate the benefits of using Xdebug.
Configuring Eclipse and Xdebug isn’t difficult. In fact its painless with the correct steps on hand. That’s where this guide comes in. I found myself coming across incomplete or outdated forum posts and stackoverflow questions, so I thought I’d post what worked for me.
If you already have Java and Eclipse installed, then just jump ahead to installing and configuring the PHP Development Tools and Xdebug.
This will install ~118 new packages, assuming you’ve not already installed some of them, and will total around 255 MB that need to be downloaded.
Install PHP Development Tools (PDT)
sudo apt-get install php5-xdebug
xdebug.remote_enable = 1
xdebug.remote_handler = “dbgp”
xdebug.remote_host = “localhost”
xdebug.remote_port = 9000
Scroll to the bottom and add:
sudo /etc/init.d/apache2 restart
<?php phpinfo(); ?>
Source URL: http://kyleabaker.com/2012/09/17/debugging-php-in-ubuntu-using-eclipse/
Copyright ©2013 kyleabaker.com unless otherwise noted.