You need to install the PHP Debug Extension in Visual Studio /Codium.
You can get all the relevant settings from here:
https://github.com/xdebug/vscode-php-debug
My test server is on 192.168.10.1
Make sure you have xdebug installed and loaded on your webserver first. Set these in your php.ini file.
[Debugger]
xdebug.remote_enable = true
xdebug.remote_host = 127.0.0.1
; Think this is required
xdebug.remote_mode = req
; Check the defaults
;xdebug.remote_port = 9000
; not sure if this wil log - probably but I don't use it
;xdebug.remote_log = /var/log/xdebug.log
Get a remote debug proxy - this is the Active state version that I am using. I think it is bundled here:
https://www.activestate.com/products/komodo-ide/download-ide/
Or just the Debug package here:
https://code.activestate.com/komodo/remotedebugging/
Here is the debug setup that I am using in Codium. Go to Run and Debug and set this up as launch.json
Name can be any name for your config. Key is your key that you register with.
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "vscphpdebug",
"type": "php",
"request": "launch",
"stopOnEntry": true,
"proxy": {
"enable": true,
"host": "192.168.10.1",
"port": 9001,
"key": "myvsc",
"allowMultipleSessions": true
},
"pathMappings": {
"/remote/server/directory": "${workspaceFolder}"
},
},
]
}
Save the JSON file.
Next run your debug proxy on your webserver
#!/bin/sh
python /root/dbgp/bin/pydbgpproxy -d 127.0.0.1:9000 -i 192.168.10.1:9001 -l DEBUG
Now in VS/Codium you can see a green run button next to "vscphpdebug". Click it or press F5 and it will connect to the server - you should get a registration message
Registering myvsc on port 9003 with proxy @ 192.168.10.1:9001
Registration successful
Now run your code from Firefox - no extensions required
https://192.168.10.1/zTest.php?XDEBUG_SESSION_START=myvsc
Or alternatively from the server command line:
php -f ./zTest.php?XDEBUG_SESSION_START=myvsc
Another user can use their own key and connect their own instance to the same webserver. Just use a different user key in the launch.json
To stop the connection use Shift + F5
If you are debugging a API file to a website you can add the XDEBUG part to a call and that will then trigger debugging on the web app as well eg:
$curl = new Curl();
$url = "https://192.168.10.1/webapp/index.php?XDEBUG_SESSION_START=users";
$post_data = array(
'username' => 'admin',
'password' => 'password'
'data' = > 'some data'
);
$curl->post($url, $post_data);