I haven\'t quite figured this out. EVERY piece of documentation I\'ve found covers how to use xdebug to debug scripts running in Apache. I need to debug a php CLI script.
For Windows and Visual Studio Code here's how to proceed:
Download xdebug from https://xdebug.org/download. For example php 7.4 Windows 64bit https://xdebug.org/files/php_xdebug-2.9.5-7.4-vc15-nts-x86_64.dll
Copy the xdebug dll to your php extensions dir (ext).
Add to the end of php.ini
[XDebug]
zend_extension=php_xdebug-2.9.5-7.4-vc15-nts-x86_64.dll
xdebug.remote_enable=1
xdebug.remote_autostart=1
Open VSCode and install https://marketplace.visualstudio.com/items?itemName=felixfbecker.php-debug
Open the project workspace in VSCode, go to Run tab, click the cogwheel and add these lines
{
"name": "listen CLI",
"type": "php",
"request": "launch",
"port": 9000
},
{
"name": "run CLI",
"type": "php",
"request": "launch",
"program": "${file}",
"cwd": "${fileDirname}",
"port": 9000
}
Place a break point in the script you want to debug
Select "run CLI" and click "Start Debugging"
Happy debugging!