Debug PHP sites from Aptana in Ubuntu

Large PHP developments, like Joomla!, Magento or PrestaShop can be very complex to debug without using a tool that provides variable inspections and breakpoints. This article describes how to configure your Ubuntu development machine with debug capabilities.

1Install Xdebug

Xdebug is a PHP extension for powerful debugging, using BDGp protocol, that can be linked to Aptana, so it catches all breakpoints from your local web server, in this case, Apache.

1.1. Install package

In Ubuntu 12.04, as simple as:

sudo apt-get install php5-xdebug

1.2. Configure

In case you need it in order to change port, i.e., configuration file is /etc/php5/apache2/conf.d/xdebug.ini. This are the standard contents:

1.3. Restart Apache

2Aptana configuration

2.1. General preferences

First, check that Xdebug is properly configured in Window → Preferences → Aptana Studio → Editors → PHP → Debug. It should be in the installed debuggers, and with the same port that is in xdebug.ini.

Now you should make Aptana to use an external browser, in Window → Preferences → General → Web Browser.

2.2. Debug configurations

Next step is tell Aptana how will debug. Go to Run → Debug Configurations, select PHP Web Page, and press the 'New' button. Select XDebug as server debugger and create a new PHP server, with following data:

3.1. Mozilla Firefox

3.2. Google Chrome

4Debug!

That's it! You can now switch to debug perspective in aptana, add breakpoints in your code, inspect variable values, etc. Just enable debug in your browser, navigate to a page that uses your PHP script and wait for your breakpoint to jump.