Debug php in emacs with geben


While PHP-developing it sometimes is just too tedious to do those ‘add a echo here and there, then reload and search the echoed strings on the screen’-loops. So I searched for a debugger for my favourite editor emacs. After a lengthy install procedure I finally got it running: With geben on emacs you can debug PHP (step through and evaluate expressions)

geben in action


Install xdebug php5-module

get xdebug for php (See “xdebug für ubuntu (german)”)

sudo pecl install xdebug

→ File lies at /usr/lib/php5/20060613+lfs/

edit php.ini (see “easy php debugging using debug and vim”)

Put these under “Module Settings”:

  ; Remote settings. Adapt if you're not running apache on localhost

Restart apache:

/etc/init.d/apache2 restart

Install required packages

Unfortunately, geben doesn’t work with the ubuntu “gutsy gibbon” packages. So do not do apt-get eieio. Instead: download cedet and eieio from and copy both into ~/elisp/

cd ~/elisp/
tar -xzvf *.tar.gz
cd cedet*
cd ../eieio*

add this to .emacs:

(add-to-list 'load-path "~/elisp/eieio-0.17")
(load-file "~/elisp/cedet-1.0pre4/common/cedet.el")

get debugclient from (currently: this file)
rename it to debugclient and move to /usr/local/bin/

install geben

download geben from
unpack it into ~/elisp/

add this to your .emacs-file:

(add-to-list 'load-path "/home/phred/elisp/geben")
(add-to-list 'load-path "/home/phred/elisp/geben/gud")


Restart emacs. Type alt-x geben. Load the script you want to debug in firefox with ?XDEBUG_SESSION_START=1 appended

Voilà, that’s it. After pressing space to ‘activate’ geben you can use this keys:

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
e   eval expression (to inspect variables: best is probably print_r($this, true))
q   stop debugger

Update: After some usage it bugged me to always type print_r($var, true) to inspect a variable. And then, the print_r-output is cut after 1024 chars. Knowing absolutely nothing about lisp I did some very lame changes to the geben code.

With these changes I’m able to type ‘E’ and then write $variable and geben writes all the output to the message-buffer. Download the diff and patch the geben-sourcecode with

patch -i geben.diff

3 Kommentare

  1. Yoan
    15. Aug 2008, 11:33

    At the beginning of this blog post is a picture pointing to the .diff; MSIE is teh good boy this time and shows it.


  2. philipp
    15. Aug 2008, 12:34

    Hi Yoan

    thanks for the hint. I’ve fixed it. Yes, IE sometimes even has advantages :-)

  3. McknightChandra
    25. Aug 2011, 04:28

    Following my analysis, thousands of people all over the world get the business loans at good banks. Therefore, there’s good possibilities to find a term loan in all countries.


Sorry, comments for this entry are closed at this time.