Install xdebug (Dockerfile example)
# 3.1.5 because of php7.4l (based on FROM php:7.4-apache)
RUN pecl install xdebug-3.1.5 && docker-php-ext-enable xdebug
Path map the config file via a bind mount:
lal:
container_name: omegalal
build: "./ze-img"
ports:
- "80:80"
volumes:
- ./html:/var/www/html
- ./xdebug-cm/xdebug.ini:/usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini
(You can figure out which config etc is loaded by using xdebug_info(); PHP function)
Create ./xdebug-cm/xdebug.ini:
zend_extension=xdebug
[xdebug]
xdebug.mode=develop,debug
; ipconfig getifaddr en0
xdebug.client_host=192.168.102.197
xdebug.start_with_request=yes
launch.json needs pathMappings:
{
"version": "0.2.0",
"configurations": [
{
"name": "Listen for XDebug on Docker",
"type": "php",
"request": "launch",
"port": 9003,
"pathMappings": {
"/var/www/html/": "${workspaceFolder}"
}
}
]
}
Note that the pathMappings (/var/www/html/) refer to the DirectoryIndex in the Docker container!