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!
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:
You can then run the binary with ./debugclient
.
On a different shell, you then run the following:
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With