4

I'm struggling with a PHP maintenance script and I was looking for a way to use xdebug solely in command line (like gdb old-school), but I couldn't figure out how to set a breakpoint, do a step-into, step-over and continue. Xdebug is up and running, as phpinfo(); says.

I found a lot of documentation regarding how to do this using Eclipse and other tools, but none to CLI. Could anyone help me? My environment is Centos 6 and Bash.

Any help is appreciated.

Thank you!

Danny Beckett
21k27 gold badges114 silver badges144 bronze badges
asked Nov 8, 2012 at 7:56

1 Answer 1

8

This is actually possible. In the Xdebug source downloads, you will find a directory called "debugclient". In this directory you will find a very simple client accepting raw DBGP commands, and giving output as XML. To compile, you run:

  • apt-get install libedit-dev (or equivalent)
  • ./buildconf
  • ./configure --with-libedit
  • make

You can then run the binary with ./debugclient.

On a different shell, you then run the following:

  • export XDEBUG_CONFIG="idekey=dr"
  • php -dxdebug.remote_enable=1 yourscript.php

The debugclient sees this connection, and you then can issue direct DBGP commands. For a breakpoint, you can for example set:

breakpoint_set -i 1 -t line -f file:///path/to/yourscript.php -n 42

the -i 1 is required to be an increasing number, -f is the file and -n the line number. After setting the breakpoint you can then run run -i 2 to advance to that line. For all other commands, I'd refer you to the DBGP documentation at http://xdebug.org/docs-dbgp.php

answered Nov 12, 2012 at 13:37

1 Comment

Since xdebug is enclosed with default php 5.3 package (that i installed at Ubuntu) so in this case what steps would be there to assign breakpoint on php script at command line?

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.