Debug PHP in IntelliJ IDEA

IntelliJ IDEA 9.0.1 has support for PHP. And the fine folks at JetBrains have given debug support which is awesome squared !

In just a few minutes you can get debug going on for your PHP applications.
Note : These instructions are for the ultimate edition of IDEA ( not the community edition which does not have php support ), and Ubuntu 10.04.
1. Install xdebug :
sudo apt-get install php5-xdebug
2. Add xdebug configuration at the end of php.ini
sudo vi /etc/php5/apache2/php.ini
Append these lines at the end
xdebug.remote_enable=On
xdebug.remote_host=”localhost”
xdebug.remote_port=9000
xdebug.remote_handler=”dbgp”
3. Restart apache
sudo /etc/init.d/apache2 restart
4. In IntelliJ here is how I have configured. It is quite simple actually.
Here is the Run configuration

Here is the PHP Setting. Point the server root to your folders.

5. Now put a break point in your code and click on the debug button. A new browser window will be launched, navigate to the page you are testing and voila – it hits the break point.
I am yet to figure out how to display the variables with the values on the bottom pane. For now doing a mouse over shows the values which is good enough for me.
Happy Debugging !

Leave a Reply

Your email address will not be published. Required fields are marked *