devilbox: XDEBUG on Windows not working

  • Which operating system are you at (Linux, OSX or Windows) Windows 10 Pro 1709 16299.248
  • docker version Version 17.12.0-ce-win47 (15139)
  • docker-compose version 1.18.0

I’m trying Devilbox as an alternative to other Docker Wordpress setups I’ve been using. I’m managed to get it working up to the point of a WordPress install, all hooked up and working fine. It’s very fast, much better than 10ups Docker for WP.

However, I can’t get XDEBUG from VSCode to attach. Without debug, it’s pretty much useless. I’m pretty certain I need to use the vEthernet Default Switch IP address, and Code is definitely listening on port 9000 when I enter debug mode. But it doesn’t hit breakpoints at all, so it’s obviously not connecting.

Could it be the path mappings are wrong in the Launch Config? { // 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": {
            "/shared/httpd/wordpress1": "${workspaceRoot}/data/www/wordpress1/htdocs"
        }
    },
    {
        "name": "Launch currently open script",
        "type": "php",
        "request": "launch",
        "program": "${file}",
        "cwd": "${fileDirname}",
        "port": 9000
    }
]

}

Any tips?

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Comments: 16 (8 by maintainers)

Commits related to this issue

Most upvoted comments

This is broken for me again now and I can no longer get XDebug to work.

Update: Fixed by doing the following

using the vEthernet (Default Switch) IP address as outlined previously in Launch.json “/shared/httpd/phptest/htdocs”: “${workspaceRoot}/data/www/phptest/htdocs” NOT workspaceFolder as you have in the docs

I got XDebug working with the PR: #203 but with some modification to your instructions. I successfully got a breakpoint hit in a phpinfo.php test file in the root of htdocs, which is my initial Xdebug test.

Here’s the configuration, assuming you are using PR: #203 xdebug.ini in E:\Source Control\Docker\devilbox1\cfg\php-fpm-7.1\ (or whatever your path is)

xdebug.remote_enable = 1 xdebug.remote_connect_back=0 xdebug.remote_autostart = 1 xdebug.remote_host=192.x.y.z

Note: xdebug.remote_host should be the IP Address of the Hyper-V Virtual Ethernet Adaptor, not DockerNat IP address. You can see this in Win 10 Task Manager performance tab or use ipconfig There’s 4 of these on my system, the one that works for me has Adapter Name: vEthernet (Default Switch) NOT the vEthernet (DockerNAT) IP.

Also Note: this is different from what they say here https://forums.docker.com/t/solved-how-to-setup-xdebug-and-phpstorm/13641/23 but it’s what works on my system using Native Docker for Windows

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": 9000,
        "pathMappings": {
            "/shared/httpd/wordpress1/htdocs": "${workspaceRoot}/data/www/wordpress1/htdocs"
        }
    },
    {
        "name": "Launch currently open script",
        "type": "php",
        "request": "launch",
        "program": "${file}",
        "cwd": "${fileDirname}",
        "port": 9000
    }
]

}

What you should do is:

  1. Use the new php images from this PR: https://github.com/cytopia/devilbox/pull/203

    • This PR contains description for how to check it out
    • It will be merged soon, but is different from current master (which will be deprecated)
  2. in the new PR, there is no .env setting for xdebug, you need to add this to php.ini yourself.

    • go to cfg/php-fpm-5.6/ (or any other version u require)
    • create a file xdebug.ini with the following content:
xdebug.remote_connect_back=0
xdebug.remote_host=192.168.246.1 

But wait

You need to change the IP address and use your own.

How to get your IP address:

In a Windows command-line, run “ipconfig” and look for the IP4 address in “DockerNAT” entry. 192.168.246.1 in my case

Let me know if this works

Edit:

Credits to this post: https://forums.docker.com/t/solved-how-to-setup-xdebug-and-phpstorm/13641/23