分类: Python/Ruby
2011-11-25 18:09:39
It’s an Emacs weekend here at blog.arithm.
I was recently asked if it was possible to do remote PHP debugging with Emacs. We’re talking about Emacs, so the answer is: Of course! How to do it:
Now, assuming you already have xdebug plugged into PHP, modify php.ini or an .htaccess file with the following settings:
For security reasons it’s wiser to do this via .htaccess on directories that permit only authenticated access.
To debug, ask Emacs to listen for connections by going into GEBEN Mode with Meta-x geben. You should see “xdebug started.” in the status row at the bottom of the Emacs window.
Run your PHP script with the xdebug switch on, eg.
If everything is setup correctly, Emacs will load the source of script.php (be wary of security!) and allow you to step through the code.
Available commands are:
spc step into/step over
i step into
o step over
r step out
b set a breakpoint at a line
u unset a breakpoint at a line
g run
q stop
Some gotchas: I’ve noticed the GEBEN expects the first keystroke to be “space”; often it will freeze otherwise. GEBEN may also run into problems on certain session-related PHP commands.