Skip to content

Instantly share code, notes, and snippets.

@vladiiancu
Last active April 13, 2021 05:02
Show Gist options
  • Save vladiiancu/1e83e0fead2f1477b84dc1c463df27d0 to your computer and use it in GitHub Desktop.
Save vladiiancu/1e83e0fead2f1477b84dc1c463df27d0 to your computer and use it in GitHub Desktop.
xDebug, VSCode and docker
server {
listen 80;
index index.php index.html;
server_name localhost;
error_log /logs/nginx/error.log;
access_log /logs/nginx/access.log;
root /app/public;
location ~ \.php$ {
try_files $uri =404;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass php:9000;
fastcgi_idnex index.php;
}
}
version: '3.1'
services:
web:
image: nginx:latest
ports:
- "3000:80"
volumes:
- ./app:/app
- ./logs/nginx:/logs/nginx
- ./nginx/xdebug:/etc/nginx/xdebug
- ./nginx/hosts:/etc/nginx/hosts
- ./nginx/init.conf:/etc/nginx/conf.d/default.conf
networks:
- app-network
depends_on:
- php
php:
build:
dockerfile: Dockerfile
context: ./
volumes:
- ./logs/xdebug:/logs/xdebug
- ./logs/php-fpm/:/tmp/xdebug_log
- ./php/custom.conf:/usr/local/etc/php-fpm.d/xy-custom.conf
- ./php/xdebug.ini:/usr/local/etc/php/conf.d/xy-xdebug.ini
env_file:
- ./.env
networks:
- app-network
FROM php:7.4-fpm
RUN pecl install xdebug \
&& docker-php-ext-enable xdebug
{
"version": "0.2.0",
"configurations": [
{
"name": "xDebug listen",
"type": "php",
"request": "launch",
"port": 9003,
"stopOnEntry": true,
"pathMappings": {
"/app": "${workspaceFolder}/app"
}
}
]
}
zend_extension = xdebug.so
xdebug.log = "/logs/xdebug/remote.log"
//this path works with the volume already set up in docker-compose where we mount the /logs/xdebug folder.
xdebug.mode = debug,profile,trace
xdebug.start_with_request = yes
xdebug.discover_client_host = 0
xdebug.client_port = 9003
xdebug.client_host=host.docker.internal
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment