Experience in Software and DevOps Engineering, with an in-depth interest in technology. Outside of work, I find joy in savoring a cup of coffee, music, and spending time with dogs and guinea pigs.
I tried to tell my xdebug (in docker) the ip of my Windows Host hardcoded and via host copied from wsl to docker (that worked for another case), but the breakpoints were never hit.
Unfortunately I do not have any logs.
Here's my setup:
xdebug.ini
zend_extension=xdebug.so
xdebug.mode=debug,develop
xdebug.client_host=172.28.32.1
#same port as in launch.json
xdebug.client_port=9003
xdebug.idekey=VSCODE
xdebug.start_with_request=yes
launch.json
{
"version": "0.2.0",
"configurations": [
{
"name": "Listen for XDebug on Docker",
"type": "php",
"request": "launch",
"port": 9003,
"pathMappings": {
"/amadeus360": "${workspaceFolder}"
},
},
]
}
A few days I ago I had to sovle the same problem again, because I hat to re-setup my local develpment. I was really happy to find my old setup here :-D
On Windows with WSL2 and Docker I had to add the "hostname" property to the launch.json with the value "0.0.0.0". "hostname": "0.0.0.0"
Also, I didn't have to specify my IP address on the xdebug.ini host field. I used the host.docker.internal, xdebug.client_host='host.docker.internal' and xdebug.discover_client_host=0
Experience in Software and DevOps Engineering, with an in-depth interest in technology. Outside of work, I find joy in savoring a cup of coffee, music, and spending time with dogs and guinea pigs.
Thanks for adding the notes, I really appreciate it!
I just would like to leave it an observation about setting xdebug.client_host=host.docker.internal... Last time I've checked this didn't work for all OS (Linux, Mac, and Windows) while setting the IP works for the three of them.
For anyone else reading this comment, if your OS works by setting the client host this way, I recommend that you do it because it will save you from having to update your IP address from time to time.
Also, you probably had to set "hostname": "0.0.0.0" because of the change at the xdebug.client_host but it's not a big change.
On the fpm container. Note: I didn't have the chance to test it
The main reason I used host.docker.internal is to be able to use this one different machines without having to change anything, or sharing with others.
Again, thanks a lot for your article. It was one the best written that I found on this topic
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Hi @apmyp1990, what problems are you facing?
Do you have any logs that you can share?
I tried to tell my xdebug (in docker) the ip of my Windows Host hardcoded and via host copied from wsl to docker (that worked for another case), but the breakpoints were never hit.
Unfortunately I do not have any logs.
Here's my setup:
I solved the problem - this line was missing:
Kudos for posting the answer to your problem after you'd solved it.
A few days I ago I had to sovle the same problem again, because I hat to re-setup my local develpment. I was really happy to find my old setup here :-D
On Windows with WSL2 and Docker I had to add the "hostname" property to the launch.json with the value "0.0.0.0".
"hostname": "0.0.0.0"
Also, I didn't have to specify my IP address on the xdebug.ini host field. I used the host.docker.internal,
xdebug.client_host='host.docker.internal'
andxdebug.discover_client_host=0
Thanks a lot for your great article
@tkorakas how are you doing?
Thanks for adding the notes, I really appreciate it!
I just would like to leave it an observation about setting xdebug.client_host=host.docker.internal... Last time I've checked this didn't work for all OS (Linux, Mac, and Windows) while setting the IP works for the three of them.
For anyone else reading this comment, if your OS works by setting the client host this way, I recommend that you do it because it will save you from having to update your IP address from time to time.
Also, you probably had to set
"hostname": "0.0.0.0"
because of the change at thexdebug.client_host
but it's not a big change.Once again, thanks for adding the notes.
Your comments makes absolute sense and it might save a lot of time from people reading this article.
Linux users where
host.docker.internal
is not working could try to add this lines on their docker compose fileOn the fpm container. Note: I didn't have the chance to test it
The main reason I used
host.docker.internal
is to be able to use this one different machines without having to change anything, or sharing with others.Again, thanks a lot for your article. It was one the best written that I found on this topic