Is the Laravel Sail xDebug documentation correct? #38678
-
Today I tried the new xDebug feature from Sail and I stumbled on this paragraph:
I tried to follow these instructions, because I am using Ubuntu 18.04. It was pretty hard, because you need to know the host-ip-address before you start the container. I only managed to do this by restarting the container a couple of times until I saw a pattern and was able to guess the next container ip. I also tried to use |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 1 reply
-
I'm thinking you may be right. TL;DR - As far as I can tell, all you need to do (assuming you are on Laravel 8 using Sail) is set My setup:
{
"name": "Listen for Xdebug",
"type": "php",
"request": "launch",
"pathMappings": {
"/var/www/html": "${workspaceFolder}"
},
"xdebugSettings": {
"max_data": 65535,
"show_hidden": 1,
"max_children": 100,
"max_depth": 5
}
}, I did a I put a breakpoint on one of the I had played around with various values in the I also have a Macbook Pro running Big Sur 11.6, with Docker (also version 20.10.8) running locally and Edit to add: This might also be dependent upon your Docker version. Apparently the Source: https://stackoverflow.com/a/61424570/5607109 |
Beta Was this translation helpful? Give feedback.
-
I think the documentation indeed needs to be updated. Firstly, as mentioned by @iwasherefirst2 you have to know the host-ip-address before you start the container, and I'm not sure if this is even possible since the IP is assigned after starting the container. Secondly, in recent versions of the docker engine (from 20.04 I think, you may see the github discussion here), the gateway address can be exposed on linux (Docker for Mac and Windows already exposed the host.docker.internal hostname), and this is already supported by Sail 1.12.12, since the docker-compose.yml that is created by Sail includes the host.docker.internal in extra_hosts (see PR here). Therefore, when running xdebug client (e.g. VSCode) on the host machine and using the current versions of Docker and Sail (I'm using Sail 1.12.12 (using docker image laravelsail/php81-composer:latest), Docker 20.10 and Docker compose 1.29.2 on Linux), the Furthermore, since Sail supports Devcontainer and also includes documentation about it, I would suggest that the documentation should also mention the option of debugging using a Devcontainer. In this case, the xdebug client listens within the app container, therefore the SAIL_XDEBUG_CONFIG needs to be overriden in .env, like so:
This setting allows xdebug to connect to VSCode which is connected to the devcontainer. Let me know what you think, I could open a PR. |
Beta Was this translation helpful? Give feedback.
-
This has been addressed now laravel/docs#9887 (comment) |
Beta Was this translation helpful? Give feedback.
This has been addressed now laravel/docs#9887 (comment)