XDebug, PHP and Sublime Text 2 on Ubuntu 12.04
Getting Xdebug for PHP working with Sublime Text 2 is slightly tricky.
Most of the instructions are at https://github.com/Kindari/SublimeXdebug - these notes are just a bit extra as a reminder to myself.
After installing Xdebug with "sudo apt-get install php5-xdebug", you have to add some xdebug settings in /etc/php5/conf.d/xdebug.ini:
zend_extension = /usr/lib/php5/20090626+lfs/xdebug.so
xdebug.remote_enable=On
xdebug.remote_host="localhost"
xdebug.remote_port=9000
xdebug.remote_handler="dbgp"
xdebug.remote_autostart=1
In ST2, you use SHIFT+F8 to get the Xdebug menu, and select "Start debugging". In your browser session, add a url parameter like this:
?XDEBUG_SESSION_START=sublime.xdebug
The page request should hang while the debugger has control - if nothing's happening in ST2, you'll need to check the console window by using "CTRL`".
You may get this output:
Traceback (most recent call last):
File "./sublime_plugin.py", line 362, in run_
File "./Xdebug.py", line 553, in run
File "./Xdebug.py", line 97, in read
File ".\xml\dom\minidom.py", line 1927, in parseString
File ".\xml\dom\expatbuilder.py", line 32, in <module>
File ".\xml\parsers\expat.py", line 4, in <module>
ImportError: No module named pyexpat
In which case you've got the problem with Python versions - 2.7 is the default on Ubuntu 12.04, and ST2 and the Xdebug plugin are using Python 2.6.
So follow the instructions at the bottom of the README at https://github.com/Kindari/SublimeXdebug
On Ubuntu 12.04, Python 2.6 isn't available, so here's what worked for me:
* Download python2.6 files from <a href="http://packages.ubuntu.com/lucid/python2.6">Ubuntu Archives</a>
* Extract the files: dpkg-deb -x python2.6_2.6.5-1ubuntu6_i386.deb python2.6
* Copy the extracted usr/lib/python2.6 folder to {Sublime Text directory}/lib
(I actually copied the usr/lib/python2.6 directory to /usr/lib/python2.6, and symlinked to there from {Sublime Text directory}/lib)
Then restart ST2 and try again. Once you hit a breakpoint, it should look like this, with the Xdebug Context and Xdebug Stack windows showing content: