Xdebug Support: PHP debugging

I took another stab at it and got DevKinsta Xdebug working. I used my XDebug 3 config from Devilbox.

The following is for an example WordPress install, testing by breakpointing the index.php in the root directory of “YourSiteName”. Running on PHP 7.4, change as appropriate for other versions.

Pull up a windows terminal, then:

Install XDebug into DevKinsta Php if needed:
docker exec devkinsta_fpm bash -c “apt-get update;apt-get -y install php7.0-xdebug php7.1-xdebug php7.2-xdebug php7.3-xdebug php7.4-xdebug php8.0-xdebug”
docker restart devkinsta_fpm

then

docker exec -it devkinsta_fpm bash
cd /etc/php/7.4/fpm/conf.d
nano 20-xdebug.ini

Edit it to:
zend_extension=xdebug.so
xdebug.mode = debug
xdebug.start_with_request = yes
xdebug.client_port = 9003
xdebug.idekey = VSCODE
xdebug.client_host = host.docker.internal
xdebug.log = /var/log/php/xdebug.log

save, exit back to windows terminal prompt

docker restart devkinsta_fpm

.vscode launch.json

{
  "version": "0.2.0",
  "configurations": 
[
    {
      "name": "Xdebug for Project YourSiteName",
      "type": "php",
      "request": "launch",
      "port": 9003,
      "pathMappings": {
        "/www/kinsta/public/YourSiteName": "${workspaceRoot}"
      }
    },

    {
      "name": "Launch currently open script",
      "type": "php",
      "request": "launch",
      "program": "${file}",
      "cwd": "${fileDirname}",
      "port": 9003
    }
  ]
}
3 Likes