Debugging symfony (or any php script) with vim and Xdebug
Comments
Display comments as
(Linear | Threaded)
|
July '08 | |||||
| Mon | Tue | Wed | Thu | Fri | Sat | Sun |
| 1 | 2 | 3 | 4 | 5 | 6 | |
| 7 | 8 | 9 | 10 | 11 | 12 | 13 |
| 14 | 15 | 16 | 17 | 18 | 19 | 20 |
| 21 | 22 | 23 | 24 | 25 | 26 | 27 |
| 28 | 29 | 30 | 31 | |||

Posted by Pierre in
Uncategorized
Thursday, January 24. 2008
Xdebug is one of the best debugger and profiler for php (maybe the only good one in open source
. The only problem is its lack of dedicated client (there is some work being done for a client but it targets only windows for now), however there is many plugins for many IDE or editors like Eclipse PDT or weaverslave and even for my favourite editor, Vim.
The vim plugin I will use here has been originally written by Seung Woo Shin and modified/improved by Sam Ghods. I find Sam’s version less noisy and seems to work better. As far as I rembember it is also included in Andrei’s vim script (I don’t have it at hand, but check the Andrei’s talk about php and vim, the url should be in there)
The first step is to install Xdebug, this procedure is well described in the Xdebug documentation. Check it out here. Don’t forget to enable the extension in your php.ini (the one used by your webserver, fcgi or cli) using
[Bash] zend_extension=/path/to/lib/php/extensions/xdebug.so
or if you use a debug build of php:
[Bash] zend_extension_debug=/path/to/lib/php/extensions/xdebug.so
To run this plugin you will need the python interpreter in Vim, you can verify whether vim has it enabled or not using the following command in Vim:
[Bash] :version
Be sure to see "+python and +signs" in the list. If you miss them, recompile Vim with "—enable-pythoninterp" or install it using your favourite package manager. For Ubuntu, this command should give you all you need (ubuntu does not install a full vim per default):
[Bash] apt-get install vim-full python2.5
Fetch the plugin archive here
Extract the archive in your plugin directory, usually ~/.vim/ or /usr/share/vim/addon/. It should look like:
[Bash] /home/johndoe/.vim/plugin/ |-- debugger.py `-- debugger.vim
To tell Xdebug to initialize a debug session, you can pass an extra GET parameter called XDEBUG_SESSION_START:
[Bash] http://testsym.local/frontend_dev.php/home?XDEBUG_SESSION_START=1
The debugger will not start magiclly
You have to ask the plugin to wait for Xdebug to send him a signal and the debugging data. Do it by pressing "F5" while being in vim and quickly switch to your browser to reload your page. If vim does nothing but idle after you pressed F5, double check the plugin install, it is not working.
And a little screenshot to show how fantastic are Vim and xDebug:

ps: how to make a pookey happy ![]()
Andris - #1 - 2008-01-25 09:22 - (Reply)
Firefox "xdebug helper" add-on: https://addons.mozilla.org/en-US/fi…
Edward Z. Yang - #3 - 2008-01-26 21:48 - (Reply)
I can’t seem to get this to work with GVim on Windows. Any hints/known issues? I extracted the plugin in C:\Program Files\Vim\vim71\plugin but Vim doesn’t seem to see it
Pierre - #4 - 2008-01-28 04:35 - (Reply)
Hi Edward, take a look here: http://agateau.wordpress.com/2007/1… this post explains how vim works on windows (for its path)