docker versiondocker-compose versionI'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?
"pathMappings": {
"/shared/httpd/wordpress1": "${workspaceRoot}/data/www/wordpress1/htdocs"
}
From an initial view, the paths don't match. Shouldn't the left be "/shared/httpd/wordpress1/htdocs".
Also here is some other information I just found: https://stackoverflow.com/questions/37478387/how-to-setup-xdebug-and-phpstorm-with-docker-for-windows-beta
Are you using native Docker or Toolbox for windows?.
Either way I am happy to get this sorted with u as i am currently writing the documentation for xdebug and windows is still the missing part.
What you should do is:
Use the new php images from this PR: https://github.com/cytopia/devilbox/pull/203
in the new PR, there is no .env setting for xdebug, you need to add this to php.ini yourself.
cfg/php-fpm-5.6/ (or any other version u require)xdebug.ini with the following content:xdebug.remote_connect_back=0
xdebug.remote_host=192.168.246.1
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
I've had a similar issue in the past with 10UP Docker and solved it as outlined here https://github.com/10up/wp-local-docker/pull/53 but it recently broke again. Pita to fix.
Which is why I'm trying Devilbox.
I'll try out the above and see if I can get it working. ty.
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
}
]
}
Great, I will add it to the documentation. New docs are going to be around here, but are still under development: http://devilbox.readthedocs.io/en/documentation/
Generalized Xdebug documentation now available: https://devilbox.readthedocs.io/en/latest/intermediate/configure-php-xdebug.html
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
Thank you so much, this point was ultimately was did it for me. I've been banging my head against this all afternoon, and using that IP isn't documented anywhere but your comment as far as I can tell.
@erythro thanks for pointing this out. I will reopen this issue until the documentation is updated accordingly.
Can you supply a screen shot of the Hypver-V Virtual Ethernet Adaptor and the command how to display this on windows.
@erythro could you also check to see if the following php.ini setting works equally well?
xdebug.remote_enable = 1
xdebug.remote_connect_back=0
xdebug.remote_autostart = 1
xdebug.remote_host = host.docker.internal
Hi @cytopia thanks, I'll give a more full explanation here, though I'm a bit out of my depth. I slightly misunderstood the comment I quoted.
I suspect the problem might have been related to some messing around with virtualisation I did ages ago with the hyper-v manager. I wanted to create an ubuntu virtual machine, but followed a guide, and part of that guide was creating a virtual switch so my virtual machine could have access to the internet (iirc).
Here's an anonymised screenshot of the output of ipconfig:

The thing that finally worked for me was setting the remote_host to 192.168.0.12, the value from "New Virtual Switch". So is it possible I set up that virtual switch in such a way that it interfered with the Devilbox and/or Docker?
Here's a screenshot of the configuration of the switch:

So the settings you asked me to use didn't work for me, but I assume that's because I wasn't actually using vEthernet (Default Switch).
@erythro thanks for the screenshots, I have added the information to the documentation and differentiated between two case:
Documentation:
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
Using IP address of vEthernet (Default Switch) instead of DockerNAT works for me on windows with docker desktop!
I have rewritten the documentation and hope it does no present what actually needs to be done in Release v1.0.1
It's suddenly no longer working for again.
The instructions also seem different again as well.
eg: now in Launch.Json you say
"/shared/httpd/mytest/htdocs": "${workspaceRoot}/htdocs"
but it used to be
"/shared/httpd/mytest/htdocs": "${workspaceRoot}/data/www/mytest/htdocs"
Xdbug is set up correctly, it's listening on 9000 as verified in Windows Resource monitor but it won't jump into a breakpoint doing a simple test with phpinfo.
I just pulled the latest Devilbox as well. This is really frustrating as Xdebug is a critical need atm.
Update: To test if it was a problem with my machine and/or Docker I've installed https://github.com/10up/wp-local-docker-v2 and successfully connected to XDebug
I still can't get Devilbox Xdebug working again so sadly will have to switch to 10up, as XDebug is essential to me.
I can't understand why Devilbox is so twitchy here though, It works, then it doesn't work and I literally spend hours trying to figure out why.