SDB
SDB is a debugger written in PHP
- Easy to use: just one-line PHP
- Network is not required, you can use it at your terminal
- No performance overhead, can be used in production live debug
- (I donot know how to translate this, but it means “SDB is strong”)
Usage
Add the following line in your code:
\Swow\Debug\Debugger\Debugger::runOnTTY();
Run your code with -e
:
php -e -d extension=swow index.php
It will show you:
____ ____ ____
/ ___| | _ \ | __ )
\___ \ | | | | | _ \
___) | | |_| | | |_) |
|____/ |____/ |____/
Enter 'r' to run your program
>
Type “r” to start debugging
Supported Commands
- Show all coroutine status (
ps
) - Inspect coroutine (
co id
) - Attach coroutine (
attach id
) - Show backtrace (
bt
) - Forward calling frame (
f index
) - Set breakpoint (
b
) - Step running (
n
) - Continue running (
c
) - List source codes (
l
) - Print variable(
p $var
) - Assign value (
p $var =x
) - Run code in coroutine (
p command0
) - Show variables (
vars
) - Find zombied coroutines(
z <timeout>
) - Kill coroutine (
kill id
) - Kill all coroutines (
killall
)
Exit debugger
Type q
to exit the debugger
If any coroutine is still running when exiting, you can use key combinations to call the debugger out.
The default key combination is sdb
+ enter, you can set this in runOnTTY()
:
\Swow\Debug\Debugger\Debugger::runOnTTY('swow');
Otherwise, the program will exit immediately.