WordPress site built using a Lando development environment.
Debugging in WordPress is enabled, as is debugging to a log file.
In VS Code I have the following launch.json
:
{
"version": "0.2.0",
"configurations": [
{
"name": "Listen for XDebug",
"type": "php",
"request": "launch",
"port": 9003,
"log": false,
"pathMappings": {
"/app/": "${workspaceFolder}/"
}
}
]
}
And this is my php.ini
:
; Xdebug
xdebug.max_nesting_level = 256
xdebug.show_exception_trace = 0
xdebug.collect_params = 0
xdebug.mode = debug
xdebug.start_with_request = yes
xdebug.client_host = ${LANDO_HOST_IP}
; Remote settings
xdebug.remote_enable = 1
xdebug.remote_autostart = 1
xdebug.remote_host = ${LANDO_HOST_IP}
When I start debugging in VS Code everything works as expected.
When debugging isn't active in VS Code (i.e. the green triangle hasn't been clicked)... I get lots of the following error in my WordPress debug log:
Xdebug: [Step Debug] Could not connect to debugging client. Tried: 172.20.0.1:9003 (from HTTP_X_FORWARDED_FOR HTTP header), 192.168.1.18:9003 (fallback through xdebug.client_host/xdebug.client_port) :-(
Is there a way to prevent Xdebug constantly trying to connect?
Is there a way to prevent Xdebug constantly trying to connect?
Yes, don't tell it to connect if you don't want it to connect. You have set xdebug.start_with_request=yes
, which means that Xdebug will do as asked, and try to make a connection. If it can't, you'll get a warning.
FWIW, the xdebug.remote_*
settings do nothing in Xdebug 3.