Last active
November 23, 2023 14:45
-
-
Save DominikStyp/f9604549097f22ab16d66cdaef758ed7 to your computer and use it in GitHub Desktop.
Docker: Install xdebug for PHP 7.4
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
version: '3' | |
services: | |
php: | |
build: | |
context: ./docker/8.2 | |
dockerfile: Dockerfile | |
args: | |
WWWGROUP: '${WWWGROUP}' | |
image: sail-8.2/app | |
extra_hosts: | |
- 'host.docker.internal:host-gateway' | |
ports: | |
- '${APP_PORT:-80}:80' | |
- '${VITE_PORT:-5173}:${VITE_PORT:-5173}' | |
environment: | |
WWWUSER: '${WWWUSER}' | |
LARAVEL_SAIL: 1 | |
XDEBUG_MODE: '${SAIL_XDEBUG_MODE:-off}' | |
XDEBUG_CONFIG: '${SAIL_XDEBUG_CONFIG:-client_host=host.docker.internal}' | |
volumes: | |
- '.:/var/www/html' | |
networks: | |
- sail | |
volumes: | |
- "./etc/php/dev/php.ini:/usr/local/etc/php/conf.d/dev.php.ini" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# install xdebug | |
# xdebug and PHP config in php.ini | |
RUN pecl install xdebug-3.1.3 | |
RUN docker-php-ext-enable xdebug |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[xdebug] | |
xdebug.remote_enable=on | |
xdebug.profiler_enable=true | |
xdebug.remote_autostart=true | |
xdebug.idekey=PHPSTORM | |
# if you enable remote_connect back you can have problems from making requests from inside the docker container | |
# because xdebug will try to connect to the docker host instead of your host where PHPStorm listens | |
xdebug.remote_connect_back=false | |
xdebug.remote_port=9003 | |
# !!! THIS IS REALLY IMPORTANT to be correct, otherwise xdebug won't work in cli !!! | |
# IP can be fetched via: | |
# 1) ifconfig | grep -A 4 docker0 | |
# 2) netstat -nr | grep '^0\.0\.0\.0' | awk '{print $2}' | |
# 3) route -n | grep 'UG[ \t]' | awk '{print $2}' | |
xdebug.remote_host=host.docker.internal | |
xdebug.remote_mode=req | |
# to enable the xdebug logs | |
# xdebug.remote_log="/var/www/html/log/xdebug.log" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[xdebug] | |
xdebug.mode=develop,debug | |
xdebug.discover_client_host=1 | |
xdebug.client_port=9003 | |
xdebug.start_with_request=yes | |
xdebug.connect_timeout_ms=2000 | |
# !!! THIS IS REALLY IMPORTANT to be correct, otherwise xdebug won't work in cli !!! | |
# IP can be fetched via: | |
# 1) ifconfig | grep -A 4 docker0 | |
# 2) netstat -nr | grep '^0\.0\.0\.0' | awk '{print $2}' | |
# 3) route -n | grep 'UG[ \t]' | awk '{print $2}' | |
xdebug.client_host=host.docker.internal | |
# to enable the xdebug logs | |
# xdebug.remote_log="/var/www/html/log/xdebug.log" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Docker host IP: 172.17.0.1 is coming from
ifconfig
output, which should be in place ofdocker0
Check out:
ifconfig | grep -A 4 docker0