laradock Docker for Windows 2.0.0.3 (31259) VSCode 1.33.1 xdebug 2.7.2 php 7.2
Set to install xdebug in workspace and PHP (.env)
...
WORKSPACE_INSTALL_XDEBUG=true
...
PHP_FPM_INSTALL_XDEBUG=true
...
Modify the two xdebug.ini as below (/php-fmp/xdebug.ini) (/workspace/xdebug.ini) xdebug.remote_host In the case of windows, it worked with docker host, but in the case of mac, it seems that it will not work unless it is set differently because the network configuration of Docker is different. xdebug.remote_port The default 9000 can be used as long as it is not used by other apps.
xdebug.remote_host=dockerhost
xdebug.remote_connect_back=0
xdebug.remote_port=9002
...
xdebug.remote_autostart=1
xdebug.remote_enable=1
xdebug.cli_color=1
If docker-compose up with this, the laradock side is ok
Install the extension PHP Debug
Create the following file in the laravel project opened in Vscode (/.vscode/launch.json) port is the value specified in xdebug.ini pathMappings is {remote document root}: {host document root}
{
"version": "0.2.0",
"configurations": [
{
"name": "Listen for XDebug",
"type": "php",
"request": "launch",
"port": 9002,
"stopOnEntry": true,
"pathMappings": {
"/var/www": "${workspaceRoot}"
}
}
]
}
You need to configure your firewall so that VS Code can communicate with Xdebug in Docker. For the time being, VS Code is set to allow communication on a private network. I try xdebug in Docker's workspace container, but I get the following error and cannot connect.
I: Connecting to configured address/port: dockerhost:9002.
E: Time-out connecting to client. :-(
After investigating various things, the network on which Docker is running is an unidentified network (public), so communication was blocked by the firewall. So you can connect by allowing VS Code to communicate over public networks, or by considering unidentified networks as private.
https://qiita.com/hiro-tarosuke/items/adcc382ca98dfb89401b https://qiita.com/ditflame/items/bf4b5f412bf607c5c6d2#%E3%83%AD%E3%83%BC%E3%82%AB%E3%83%AB%E3%83%87%E3%82%A3%E3%83%AC%E3%82%AF%E3%83%88%E3%83%AA%E3%81%8C%E3%83%9E%E3%82%A6%E3%83%B3%E3%83%88%E3%81%A7%E3%81%8D%E3%81%AA%E3%81%84
Recommended Posts