I'm trying to set a breakpoint in PHP code using XDebug with Visual Studio Code, which is all installed on an Ubuntu Hyper-V virtual machine. I'm on PHP 7.2.
Whenever I set a breakpoint in my PHP code and refresh a page which should hit the breakpoint, I get the errors "command is not available" and "no such breakpoint" shown in popups in Visual Studio Code. I also get the following error in the Debug Console.
XDebugError: command is not available
at new Response (/home/ben/.vscode/extensions/felixfbecker.php-debug-
1.13.0/out/xdebugConnection.js:56:19)
at new BreakpointSetResponse (/home/ben/.vscode/extensions/felixfbecker.php-debug-
1.13.0/out/xdebugConnection.js:207:9)
at Connection.<anonymous> (/home/ben/.vscode/extensions/felixfbecker.php-debug
1.13.0/out/xdebugConnection.js:599:20)
at Generator.next (<anonymous>)
at fulfilled (/home/ben/.vscode/extensions/felixfbecker.php-debug-1.13.0/out/xdebugConnection.js:4:58) {
code: 5,
name: 'XDebugError'
}
Based on my research, I think the problem is because XDebug doesn't work with IPv6, but the debugger is listening on v6. If I do netstat -an | grep 9000, I get
tcp6 0 0 :::9000 :::* LISTEN
Here are the contents of /etc/php/7.2/fpm/conf.d/20-xdebug.ini
zend_extension=xdebug.so
xdebug.remote_autostart=1
xdebug.remote_enable=1
xdebug.remote_handler=dbgp
xdebug.remote_host=127.0.0.1
xdebug.remote_mode=req
xdebug.remote_port=9000
xdebug.var_display_max_depth=-1
xdebug.var_display_max_children=-1
xdebug.var_display_max_data=-1
How do I fix this problem and get my breakpoint to work?