Xdebug Support: PHP debugging

Hi @Kevin are we still on track for Q4 to fully support XDebug?

(asking because ipconfig getifaddr en0 returns an external IP address and I travel a lot for work so this address will keep changing! :hot_face: Also probably explains why @Greg36 had to mess with firewall rules as the traffic is crossing interfaces)

Hi @jamesgreenblue, I believe xDebug support will be released with the next DK version (within weeks). It will probably need tweaking based on user feedback, though. Weā€™re mainly working to make it easier to set up.

The IP address issue seems to be more due to something changing with Docker. I did originally recommend a way to automatically get the correct IP with a click to our Devs but Iā€™m not sure if that will be in this release.

Iā€™ll post an update in here once the feature is live!

2 Likes

I just switched to WSL2 from HyperV and had to set up XDebug again.
I followed Kevinā€™s WSL adapted guide Xdebug Support: PHP debugging - #56 by Kevin and itā€™s working fine (PHP 8.0) for me. Thanks Kevin!

Iā€™m relieved! :joy:

PS: You can just use the IP address of the Ethernet vEthernet (WSL) you can see in the task manager.

1 Like

Hi Kevin,

This post is music to my ears. +1 from me on the need for xDebug to complete the local dev env.

Was this released? I see no mention of xDebug in the latest release line items.

Konstantin

Hi @Konstantin_Brazhnik,
This was about to be released with the current DK version, but I found a huge issue with it and we had to push back the release. We figured it was better to wait/do it right to avoid introducing performance issues.

Itā€™s currently slated for the next release of DevKinsta before the end of the year. Iā€™ll announce if it gets pushed back again, but Iā€™m hopeful for a November/December release.

2 Likes

Kevin,

Happy New Year!

Iā€™m excited to see xDebug in the release logs of the latest version of DevKinsta. Is there any documentation you can point me to about how to use it with VSCode? Iā€™d been using Valet for a while and had no issue configuring PHP and VSCode to work with xDebug, but Iā€™m not 100% sure how this translates to DevKinsta and the docker containers it runs.

Thank you!

Konstantin

Hereā€™s how I got it working. From the wrench/site configurations option in DevKinsta I made sure ā€œenable xdebugā€ was checked. In the PHP.ini editor I had the following lines:

xdebug.remote_autostart=1
xdebug.remote_enable=1
xdebug.profiler_enable=1
xdebug.profiler_enable_trigger = 1
xdebug.discover_client_host = 1

You can verify this with a phpinfo(); output, but the config on my system was still using the classic port 9000, not the 9003 XDebug 3 supposedly moved to.

I have the PHP Debugv1.30.0 extension installed in VS Code. With that in place youā€™ll have the ā€˜Run and debugā€™ option on the left. Or press Shift-Command-D to open it. Let it create a launch.json file for you.

I removed everything but the ā€œListen for Xdebugā€ configuration; itā€™s not possible to launch a script for remote execution as far as I know so they were just cluttering up the options.

hereā€™s what one of mine looks like, where my workspace is in the wordpress wp-content directory (I donā€™t want any visibility into the stock WP code or have searches find Automatticā€™s classes)

{
    // 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": "Listen for Xdebug",
            "type": "php",
            "request": "launch",
            "port": 9000,
            "pathMappings": {
                "/www/kinsta/public/devwebsite/wp-content/": "${workspaceRoot}/",
            }
        }
    ]
}

My experience has been that setting breakpoints visually can be iffy for triggering; I tend to add an xdebug() call in my code where I want it to halt. Just be careful you donā€™t leave them in when you push to Kinsta.

1 Like

Hi Don,

Thank you for sharing this information/test you did! :bowing_man: .
Hopefully that will be useful for other users as well! :+1: :smiley:

Cheers,
Agus

Awesome! this also worked for me :rocket:

Iā€™m using Windows 11 > Docker (with WSL2) > DevKinsta > WordPress Site

Considering that PHP 8.x broke some functionalities, Iā€™ve switched to 7.4 on DevKinsta.

On Windows power shell, access to docker bash:

docker exec -it devkinsta_fpm bash

then change directory where xdebug ini is:

cd /etc/php/7.4/fpm/conf.d

Modify file: vim 20-xdebug.ini

Add:

zend_extension=xdebug.so
xdebug.mode=develop,debug
xdebug.start_with_request=yes
xdebug.client_host=host.docker.internal
xdebug.client_port=9999
xdebug.idekey = VSCODE
xdebug.log = /var/log/fpm/xdebug.log
xdebug.log_level = 1

Save file, then exit docker devkinsta_fpm bash

Finally on Windows power shell restart docker with:

docker restart devkinsta_fpm

Configure .vscode/launch.json

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

Rembember to change YourSiteName with your app name.