Extracted from cytopia/devilbox#718 issue
- ~/.zshrc or ~/.bashrc
export IP=$(hostname -I)
- _~/.devilbox/.env
PROJECTS_PATH=~/code
- ~/.devilbox/docker-compose.override.yml
version: '2.3'
services:
php:
volumes:
- ${PROJECTS_PATH}/my-plug:/shared/httpd/my-site/htdocs/wp-content/plugins/my-plug
extra_hosts:
docker.for.wsl2.host.internal: ${IP}
httpd:
volumes:
- ${PROJECTS_PATH}/my-plug:/shared/httpd/my-site/htdocs/wp-content/plugins/my-plug
- ~/devilbox/cfg/php-ini-7.4/xdebug.ini
; Defaults
xdebug.mode=debug
xdebug.start_with_request=yes
xdebug.client_port=9000
; The WSL2 way
xdebug.discover_client_host=0
xdebug.client_host=docker.for.wsl2.host.internal
; idekey value is specific to Visual Studio Code
xdebug.idekey=VSCODE
- ~/code/my-plug/.vscode/launch.json
{
"version": "0.2.0",
"configurations": [
{
"name": "Listen for XDebug",
"type": "php",
"request": "launch",
"port": 9000,
"pathMappings": {
"/shared/httpd/my-site/htdocs/wp-content/plugins/my-plug": "${workspaceFolder}"
}
},
{
"name": "Launch currently open script",
"type": "php",
"request": "launch",
"program": "${file}",
"cwd": "${fileDirname}",
"port": 9000
}
]
}