I am been shown this unusual error. It has just started appearing and it’s preventing me from debugging my WSL web solution.
I am running a php wordpress site in Visual Studio code and debugging it using XDebug. I have the following in my launch.json
which I know for a fact worked yesterday and has been working fine for a while now.
When I try and debug I get a pop saying the following
I’ve never seen this message before and I can’t see any information online about it.
My launch.json looks like the following
"version": "0.2.0",
"configurations": [
{
"name":"Listen for XDebug",
"type":"php",
"request":"launch",
"port":9003,
"pathMappings": {
"server path": "${workspaceRoot}"
},
"xdebugSettings": {
"max_data": 10000,
//"show_hidden": 1,
"max_children": 250,
"max_depth": 10
},
"env": {
"XDEBUG_MODE": "debug",
"XDEBUG_TRIGGER": "VSCODE"
}
}
]
‘server path’ is the path of the project on the server.
I first thought that maybe the port was being used by something elese but it wasn’t.
I have tried restarting Apache2, reloading PHP7.3-fpm and turning my computer off in the hopes that the issue resolves itself yet nothing seems to be working.
Has anyone else came across this issue?
4
Answers
It seems that all of a sudden, for some reason
env
was not recognised and VSC no longer liked it. Replacing it withenivornment
(as per the comment GrafiCode suggested) in thelaunch.json
fixed the issue.According to @burito in the comment,
env
has been renamed to `environment.My only guess as to why this happened is that I have a
.env
file in my root that could had of been overriding the launch and so when I launched the solution, it hit the.env
file first and seen that the solution wasn't running...thereby throwing the error/ pop-up.php-debug dev here.
I have added this error because people don’t understand that without starting a program/script the debug adapter cannot influence the environment Xdebug is running in. Effectively in your launch.json the
env
does nothing.Looking back on the change, I should have introduced a warning first…
Just to clarify,
env
was NOT renamed toenivornment
.Alternatively you can use the browser extension "Xdebug helper".
If set to "debug" it sets a cookie with "XDEBUG_TRIGGER: true" which triggers the debugging when you have
start_with_request=trigger
in php.ini.(it’s also possible to add the query parameter
?XDEBUG_TRIGGER=1
to the url).