First of all, this is not a tutorial on how to setup XDebug in your PHP environment. It assumes you've already done that.
This is my .vscode/launch.json
{
"version": "0.2.0",
"configurations": [
{
"name": "Xdebug Browser",
"type": "php",
"request": "launch",
"runtimeArgs": [
"-dxdebug.mode=debug",
"-dxdebug.start_with_request=yes",
"-S",
"localhost:5500"
],
"program": "${file}",
"cwd": "${workspaceRoot}",
"port": 9003,
"serverReadyAction": {
"pattern": "Development Server \\(http://localhost:([0-9]+)\\) started",
"uriFormat": "http://localhost:%s/${relativeFile}",
"action": "openExternally"
}
},
{
"name": "Xdebug CLI",
"type": "php",
"request": "launch",
"program": "${file}",
"cwd": "${fileDirname}",
"port": 0,
"runtimeArgs": [
"-dxdebug.start_with_request=yes"
],
"env": {
"XDEBUG_MODE": "debug,develop",
"XDEBUG_SESSION": "1",
"XDEBUG_CONFIG": "client_port=${port}"
}
}
]
}
It allows me to debug files on the command line (CLI) and in the browser.
How to run through the CLI
First, open the "Run and Debug" tools of VSCodium from the icon on the left-hand side of the IDE.
Next add a break point in your code where you'd like the code to pause.
Then click the play button to the right of "Xdebug CLI"
You should now have debugging tools above your code, and variables in the variables section.
How to run through a Web Browser
First, open the "Run and Debug" tools of VSCodium from the icon on the left-hand side of the IDE.
Then click the play button to the right of "Xdebug Browser"
You should now have debugging tools above your code, and variables in the variables section.