How to setup local PHP debugging with PHPStorm and Xdebug

I am checking out a new IDE on the block – PHPStorm… well, new for me anyway :)

For Java and Python, Eclipse is all I need, but when coding in PHP, I am not a big IDE guy, for me, Vi is still the weapon of choice. But when it comes to debugging complex apps(yeah you can write those in PHP too :) , Vi doesn’t quite cut it. There are plugins for it to provide debugging capabilities(or rather Vimified interface to Xdebug), but half of the time it doesn’t work and the other half of the time it’s not what I am looking for. So far, I’ve been a user of Komodo IDE, I still have the old version 4 up and running here and do most of my debugging in it. It’s nice on one side, but somewhat cumbersome on the other.

Anyway, one major thing that always kept me from trying new IDEs is debugger setup. I tend to spend 10 minutes trying to setup debugging in new IDE, get frustrated, say fuck it, and get back to Komodo. This short blog post is to capture how I setup debugging in PHPStorm using Xdebug.
There is a video about this as to how to get a remote debugging working, but not much info about how to get a local one for folks who is on Linux(Ubuntu in my case).
So there we go:

Xdebug Setup

Step 0. Get phpize. If you’re on Ubuntu it’s as simple as running sudo apt-get install php5-dev
Step 1. Get Xdebug, it’s pure awesomeness. Just go here: and follow the instructions. Note: you can also try installing it from pecl or Ubuntu repository, but I had problems with these methods before.
Step 2. I recommend not to follow the last step of Xdebug install instructions where it says to add zend_extension line to the php.ini file. Cleaner way of enabling Xdebug and then configuring it is to add a file xdebug.ini to /etc/php5/conf.d/ folder with the following contents:

;xdebug configuration
zend_extension = /usr/lib/php5/20090626/
xdebug.remote_host =
xdebug.remote_enable = 1
xdebug.remote_port = 9000
xdebug.remote_handler = dbgp
xdebug.remote_mode = req

This xdebug.ini will be picked up by both CLI and Apache and makes it easier to control without messing with the central config file.
Once apache is restarted and xdebug succesfully loaded, time to look at phpStorm’s side.

Step 3. Get Xdebug helper extension for Chrome or similar for Firefox is very handy. Get one so you can enable/disable debugging sessions from the browser. Make sure you set it up such that is loads up on your local domain. For example, if your project runs on myproject.local, your setup will prob look like this:

PHPStorm Debugging Setup

This is a bit less straightforward, but here I go anyway. Here are my assumptions:
My project is running localy at http://myproject.local
It’s stored locally in /home/user/Projects/myproject/public ,which is also a DocumentRoot for myproject.local Vhost config in Apache. There are ‘library’ and ‘application’ folders outside of DocRoot however.

Step 1. In PHPStorm, setup path to web browser(File->Settings->Web Browsers). It actually detected all paths correctly except for Chrome, which I had to set manually(in my case it was in /usr/bin/google-chrome)

Step 2. Setup run configuration – Run->Edit Configurations. That screen is kinda odd, but here is how I got it going.
* Create new configuration, with type PHP on Server

* Create new server(click on the button next to “Server” dropdown). I picked server type “Local” and set webroot to “http://myproject.local“. On the “Mappings” tab I set local path to /home/user/Projects/myproject/public
* Save that server and select it in the Run Configurations
Ultimately my config looked as following:

This looks like it. Now opening up a file inside that project and ‘running’ it will actually bring up a new Chrome window with a page and put PHPStorm in listening mode on port 9000 for Xdebug connections. You’ll need to activate ‘Xdebug helper’ in that window, after that all interactions with the server will be intercepted by Xdebug and PHPStorm.

How to install Mono on RedHat/Plesk 8.6.x

Mono is a savior if you’re migrating Windows sites to Linux/Apache stack. I had to do this just recently and had to setup Mono on RHEL box with Plesk 8.6. It was relatively straighforward process and here is quick log as to how installed Apache Mono on Plesk:

1. Add Mono repository to yum:

wget -O /etc/yum.repos.d/mono.repo

2. Install Mono:

yum install mono-core mono-web mono-data mod_mono xsp

Note: You may get missing dependency notice.

Missing Dependency: is needed by package libgdiplus0-1.9-1.rhel4.novell.i386 (mono)
Error: Missing Dependency: is needed by package libgdiplus0-1.9-1.rhel4.novell.i386 (mono)
You could try using --skip-broken to work around the problem
You could try running: package-cleanup --problems
package-cleanup --dupes
rpm -Va --nofiles --nodigest

If that’ the case you’ll need to take a different route. Remove that /etc/yum.repos.d/mono.repo and create a new file centos-5-extras.repo and put the folloging content in there:

name=CentOS-5 - $basearch - Extras

Then run this:

yum --enablerepo=centos-5-extras install mono-core mono-web mono-data mod_mono xsp

This should do it. Just make sure mono is installed afterwards:

mono -V

3. Check & configure mod_mono
Install process should’ve created the configuration file for mod_mono. Check if it exists here: /etc/httpd/conf.d/mod_mono.conf
If it doesn’t exist there create it and put the following contents:

# mod_mono.conf
<IfModule !mod_mono.c>
LoadModule mono_module /usr/lib/httpd/modules/
AddType application/x-asp-net .aspx
AddType application/x-asp-net .asmx
AddType application/x-asp-net .ashx
AddType application/x-asp-net .asax
AddType application/x-asp-net .ascx
AddType application/x-asp-net .soap
AddType application/x-asp-net .rem
AddType application/x-asp-net .axd
AddType application/x-asp-net .cs
AddType application/x-asp-net .config
AddType application/x-asp-net .Config
AddType application/x-asp-net .dll
DirectoryIndex index.aspx
DirectoryIndex Default.aspx
DirectoryIndex default.aspx

4. Restart Apache

/usr/local/psa/admin/sbin/websrvmng -r

This did it for me. Along the way I encountered few issues, looking closesly at /var/log/httpd/error_log helped to find solutions(in my case it was missing mono-web package, that brings in System.Web library I guess).