Skip to content

Commit 06f390e

Browse files
committed
docker: add xdebug support
1 parent b632643 commit 06f390e

File tree

2 files changed

+32
-0
lines changed

2 files changed

+32
-0
lines changed

Dockerfile

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,34 @@
33

44
FROM php:8.4-apache
55

6+
# Install PHP XDebug, for step debugging.
7+
# You can leave port 9007 for all your Docker containers. It doesn't conflict across containers like the localhost port does.
8+
# Add this .vscode/launch.json file to your repo, then go to Run and Debug -> press play:
9+
# {
10+
# // Use IntelliSense to learn about possible attributes.
11+
# // Hover to view descriptions of existing attributes.
12+
# // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
13+
# "version": "0.2.0",
14+
# "configurations": [
15+
# {
16+
# "name": "Listen for Xdebug",
17+
# "type": "php",
18+
# "request": "launch",
19+
# "port": 9007,
20+
# "pathMappings": {
21+
# "/var/www/html/": "${workspaceRoot}"
22+
# }
23+
# }
24+
# ]
25+
# }
26+
RUN pecl install xdebug \
27+
&& docker-php-ext-enable xdebug
28+
RUN echo "xdebug.mode=debug" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini \
29+
&& echo "xdebug.client_host=host.docker.internal" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini \
30+
&& echo "xdebug.client_port=9007" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini \
31+
&& echo "xdebug.idekey=VSCODE" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini \
32+
&& echo "xdebug.start_with_request=yes" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini
33+
634
# Install composer. Once the container is built and running, you can do `composer update` with the following shell command: `docker exec -it citation-bot-php-1 composer update`
735
RUN apt-get update && apt-get install -y git zip unzip \
836
&& apt-get clean && rm -rf /var/lib/apt/lists/*

docker-compose.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,7 @@ services:
77
- "8082:80" # https://localhost:8082
88
volumes:
99
- .:/var/www/html
10+
environment:
11+
PHP_IDE_CONFIG: "serverName=Docker"
12+
extra_hosts:
13+
- "host.docker.internal:host-gateway" # Required for Xdebug to connect back to host

0 commit comments

Comments
 (0)