Xdebug Support: PHP debugging

Thank you! And do I also need to update the php config or is that handled automatically? I’m not sure where to update php config in docker.

The config files stored inside the containers and are automatically configured but you’re free to edit them as well. You can enter into the container via the following commands:

NGINX:
docker exec -it devkinsta_nginx bash

FPM:
docker exec -it devkinsta_fpm bash

Got it. If the xdebug install configures php correctly that works. I’ll try that and see how it goes. Thanks!

When I run this command I get:
Reading package lists…
Building dependency tree…
Reading state information…
E: Unable to locate package php7.0-xdebug
E: Couldn’t find any package by glob ‘php7.0-xdebug’
E: Couldn’t find any package by regex ‘php7.0-xdebug’
E: Unable to locate package php7.1-xdebug
E: Couldn’t find any package by glob ‘php7.1-xdebug’
E: Couldn’t find any package by regex ‘php7.1-xdebug’
E: Unable to locate package php7.2-xdebug
E: Couldn’t find any package by glob ‘php7.2-xdebug’
E: Couldn’t find any package by regex ‘php7.2-xdebug’
E: Unable to locate package php7.3-xdebug
E: Couldn’t find any package by glob ‘php7.3-xdebug’
E: Couldn’t find any package by regex ‘php7.3-xdebug’
E: Unable to locate package php7.4-xdebug
E: Couldn’t find any package by glob ‘php7.4-xdebug’
E: Couldn’t find any package by regex ‘php7.4-xdebug’
E: Unable to locate package php8.0-xdebug
E: Couldn’t find any package by glob ‘php8.0-xdebug’
E: Couldn’t find any package by regex ‘php8.0-xdebug’

Try running apt-get update && apt-get upgrade first and let us know if this helps.

Yes, that worked and it installed. Now phpinfo() shows xdebug. However, when I started Visual Studio Code with the following config I’m not getting any debugging:

{
            "name": "Listen for XDebug",
            "type": "php",
            "request": "launch",
            "port": 9003,
            "log": true,
        },
2 Likes

I’m stuck at this point too – my guess is that we need to configure Xdebug remote access so that VS code can bridge into docker but would rather receive instructions from the DevKinsta developers before starting to play with configuration files!

My understanding is that a remote connection is required for xdebug to function with Docker. Let me know if this guide here helps.

I’m not sure how to apply the guide to the docker containers, which PHP configuration files would be applicable and what should the pathMapping values be in the launch json?

What I was hoping for is something similar to the Add-On in local that configures everything:

Hi @michael

I’ve tried following the guide you shared but no joy so far (I’m using Chrome and the Xdebug browser plugin)! This is where I am:

macbookpro ~ % docker exec -it devkinsta_fpm bash

root@2dedc43b17cc:/etc/php/7.4/fpm/conf.d# cat 20-xdebug.ini 
zend_extension=xdebug.so
xdebug.remote_enable=1
xdebug.remote_autostart=1
xdebug.remote_connect_back=0
xdebug.remote_host=docker.for.mac.localhost
xdebug.max_nesting_level=1500

macbookpro ~ % exit

macbookpro ~ % docker restart devkinsta_fpm

In visual studio code my launch json is configured as below:

~/DevKinsta/public/greenfins/.vscode/launch.json:

{
    // 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": 9003,
            "pathMappings": {
                "/www/kinsta/public/greenfins": "${workspaceFolder}"
            }
        },
        {
            "name": "Launch currently open script",
            "type": "php",
            "request": "launch",
            "program": "${file}",
            "cwd": "${fileDirname}",
            "port": 9003
        }
    ]
}

For good measure I also tried the following because it looks like Xdebug 3 was installed when following the steps from @ramyallam and the guide you shared was for Xdebug 2:

root@2dedc43b17cc:/etc/php/7.4/fpm/conf.d# cat 20-xdebug.ini 
zend_extension=xdebug.so
xdebug.mode=debug
xdebug.start_with_request=yes
xdebug.idekey=VSCODE
xdebug.remote_connect_back=0
xdebug.remote_host=host.docker.internal

and…

zend_extension=xdebug.so
xdebug.mode = debug
xdebug.start_with_request = yes
xdebug.idekey = VSCODE
xdebug.remote_connect_back = 0
xdebug.remote_host = kubernetes.docker.internal

Still no joy!

I wonder whether Docker needs some more configuration as per https://sebastianhamalainen.com/blog/debug-php-with-vscode-and-docker (add XDEBUG_ENABLE and DOCKERHOST lines under x-environment in docker-compose.yml file). I can’t currently find where DevKinsta stores the compose files, are you able to give me a steer?

Could really do some input from the DevKinsta devs because otherwise I will have to go back to Local (which I really don’t want to do - Kinsta hosting has been flawless so far).

I’m sorry for the trouble here @jamesgreenblue . We’ll add this as a possible feature of DevKinsta to make this process easier for those using xdebug. I’ll move this thread over to Feature Requests category too and I’ve notified our developers.

3 Likes

No worries. Thank you for flagging to the developers – I’m happy to assist with testing (and happy to be contacted directly) if that is helpful to get to the bottom of this. Cheers.

1 Like

Hi @michael, any chance of an update on this? Really need it to move forward with some changes to our Kinsta-hosted site!

Hi @jamesgreenblue . No updates yet I’m afraid.

Hi,
Just started using DevKinsta and discovered this huge blocker to developer UX and productivity.

Has there been any progress with this?

Fwiw I’ve debugged with XDebug using Docker with Devilbox and 10up’s Docker WordPress installs, so it’s definitely possible if you can easily configure the necessary ini files and have the right info for the .vscode launch.json

One key setup variable I’ve found here is the XDebug remote host IP address, which should use the Ethernet IP Address not Virtual Switch (at least it was last time I did it with Devilbox). If you don’t get this right, no connection.
Ditto for the .vscode file/folder path.

But without official XDebug support, accurate setup information/instructions I’m wary of running down a rabbit hole trying to get this working at the moment - especially when I’m trying to solve client issues. Clients we are bringing to Kinsta btw!

Can you please prioritise this?

Interactive debugging locally is essential, logging is not a substitute when trying to solve gnarly issues -especially when you are on the clients budget time.

It would also be great if you could add support for local https://www.blackfire.io/ , which lets you profile locally.

Update:
What’s also a productivity killer is I can’t even clone the site locally to Devilbox or 10UP Docker WordPress for debugging because even the DevKinsta tool won’t let me use All-In-One-migration or Duplicator to make an easy clone.

Thanks,
Paul

2 Likes

@michael While full support for interactive debugging enabled via the UI is the ultimate goal, I would very much settle for accurate set up instructions for DevKinsta and Visual Studio Code running on MacOS! Please could this be bumped up in priority because I resonate with @sonicviz’s sentiment regarding the necessity of local debugging – I have been stuck in this rabbit hole for months now!

1 Like

Hi @sonicviz and @jamesgreenblue. I’m afraid at this time we don’t fully support Xdebug as a plug and play feature but we hope to introduce this in the future. I’m very sorry for the trouble.

I haven’t heard of that occurring before. Would you mind creating a new thread for this so we can discuss further and find out what’s going on?

Agreed–this is what keeps me from switching for devkinsta for now. Hoping this is added in a future release.

@michael Understood. Can you predict when the dev team will have time to work on it? I’m going to have to move to an alternative if its going to be more than a month or two from now!

A post was split to a new topic: Cloning Times Out