Skip to content

Instantly share code, notes, and snippets.

@glasket
Last active March 30, 2026 08:33
Show Gist options
  • Select an option

  • Save glasket/0657229582a94663629616ae21e3b893 to your computer and use it in GitHub Desktop.

Select an option

Save glasket/0657229582a94663629616ae21e3b893 to your computer and use it in GitHub Desktop.
Files needed to configure xdebug to work with VSCode, WSL2, and Docker
# This can be any init/rc style file, or you can execute it manually
export IP=$(hostname -I)
version: '3.8'
services:
web:
build: .docker/web
volumes:
- .:/var/www/html
ports:
- 80:80
extra_hosts:
- "docker.host:${IP}"
FROM php:7.4-apache
# This image makes use of php-extension-installer in order to simplify the installation of multiple extensions
ADD https://raw.githubusercontent.com/mlocati/docker-php-extension-installer/master/install-php-extensions /usr/local/bin/
RUN chmod uga+x /usr/local/bin/install-php-extensions && sync && \
install-php-extensions calendar exif ffi gd gettext pcntl pdo_pgsql pgsql shmop sockets sysvmsg sysvsem sysvshm xsl xdebug
COPY remote-php-debug.ini $PHP_INI_DIR/conf.d/remote-php-debug.ini
{
"version": "0.2.0",
"configurations": [
{
"name": "Listen for XDebug",
"type": "php",
"request": "launch",
"port": 9000,
"pathMappings": {"/var/www/html": "${workspaceRoot}"}
},
]
}
xdebug.remote_enable = 1
xdebug.remote_autostart = 1
xdebug.remote_connect_back = 0
xdebug.remote_host = docker.host
xdebug.remote_port = 9000
xdebug.idekey = VSCODE
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment