Saturday, October 09, 2010

XDebug using a Parallels VM and PHPStorm 1.0.2

I wanted to get XDebug working with my new IDE of choice: PHPStorm. I'm running a Parallels Virtual Machine (VM) with Ubuntu on it, and sharing my local folder on my Mac running Leopard.

I already had PHP 5.3.2, Apache 2.0 and mySQL running on the VM.

I installed XDebug using:
apt-get install php5-xdebug

This added a file named: "/usr/lib/php5/20090626+lfs/xdebug.so"

I then went in to /etc/php5/apache2/php.ini and added the following lines to the bottom:

zend_extension="/usr/lib/php5/20090626+lfs/xdebug.so"
xdebug.remote_enable=1
xdebug.remote_host=10.211.55.2
xdebug.profiler_enable=1
xdebug.profiler_output_dir=/tmp
xdebug.remote_log="/tmp/xdebug.txt"

----EDIT:----

Another time, I used this:

zend_extension=/usr/lib64/php/modules/xdebug.so
xdebug.remote_enable=1
xdebug.remote_host=33.33.33.1
xdebug.profiler_enable=1
xdebug.default_enable=1
xdebug.remote_handler=dbgp
xdebug.remote_port=9000
xdebug.remote_autostart=0

---------------

I also checked there was no zend lines referring to zend debuggers etc, which conflict.

The IP I used above was not the IP of the VM as reported when using ifconfig on the VM, it was instead the IP of my host machine (my mac):

ifconfig on my mac:


















I added a file phpinfo.php with to see the xdebug settings:



I now needed to set up PHPStorm to use this configuration:

Under: Run > Edit Configurations in PHPStorm:



Clicking on Server path mappings:



Above, I made sure to use the mount point that the VM was using - this was configured using Parallels > Virtual Machine > Configure > Shared Folders options tab previously when setting up my VM.

I had mapped the /media/psf/ mapping to /var/www/ using a symlink. ( ln -s)

Here is the server configuration



and the mappings tab:



I made sure my VM Apache was restarted:
/etc/init.d/apache2 restart

Now to debug, I could click the Run > Debug option in PHPStorm.

I hope this helps someone. Any questions, please email nathan [ at ] eit dot co dot nz.