Last active
November 18, 2020 10:09
-
-
Save Zayon/f8c0a404a86ece1d6c909d4a36fc6d12 to your computer and use it in GitHub Desktop.
Revisions
-
Zayon revised this gist
Jun 21, 2020 . 1 changed file with 2 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -23,7 +23,7 @@ RUN apk add --no-cache $PHPIZE_DEPS \ version: xx services: php-fpm: environment: XDEBUG_CONFIG: idekey=PHPSTORM remote_host=172.23.0.1 remote_port=10000 ``` @@ -54,7 +54,7 @@ endif version: xx services: php-fpm: volumes: - ./path/to/xdebug.ini:/usr/local/etc/php/conf.d/20-xdebug.ini.disabled environment: -
Zayon revised this gist
Jun 21, 2020 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -56,7 +56,7 @@ version: xx services: php-pfm: volumes: - ./path/to/xdebug.ini:/usr/local/etc/php/conf.d/20-xdebug.ini.disabled environment: XDEBUG_CONFIG: idekey=PHPSTORM remote_host=172.23.0.1 remote_port=10000 ``` -
Zayon revised this gist
Jun 21, 2020 . 1 changed file with 67 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -1,5 +1,7 @@ # Xdebug with Docker ## With docker dev image *Dockerfile* ``` FROM production as dev @@ -44,3 +46,68 @@ ifneq ($(CI), true) || (mv /usr/local/etc/php/conf.d/20-xdebug.ini /usr/local/etc/php/conf.d/20-xdebug.ini.disabled && kill -USR2 1)" endif ``` ## Without docker dev image *docker-compose.override.yaml* ```docker-compose.override.yaml version: xx services: php-pfm: volumes: - ./path/to/xdebug.ini:/usr/local/etc/php/conf.d/20-xdebug.ini.disabled environment: XDEBUG_CONFIG: idekey=PHPSTORM remote_host=172.23.0.1 remote_port=10000 ``` Remote host is `host.docker.internal` on mac and windows. On linux use `docker inspect <container> | grep Gateway` to find the host ip. ```Makefile .PHONY: debug-start debug-start: ## Enable xdebug ifneq ($(CI), true) docker-compose exec -T -u root php-fpm sh -c "[ -e /usr/local/etc/php/conf.d/20-xdebug.ini ] && exit 0 \ || (cp /usr/local/etc/php/conf.d/20-xdebug.ini.disabled /usr/local/etc/php/conf.d/20-xdebug.ini && kill -USR2 1)" endif .PHONY: debug-stop debug-stop: ## Disable xdebug ifneq ($(CI), true) docker-compose exec -T -u root php-fpm sh -c "[ -e /usr/local/etc/php/conf.d/20-xdebug.ini ] \ && rm /usr/local/etc/php/conf.d/20-xdebug.ini && kill -USR2 1" endif ``` Try it out: ``` $ > docker-compose exec php-fpm php -v PHP 7.4.6 (cli) (built: May 15 2020 01:43:37) ( NTS ) Copyright (c) The PHP Group Zend Engine v3.4.0, Copyright (c) Zend Technologies $ > make debug-start docker-compose exec -T -u root php-fpm sh -c "[ -e /usr/local/etc/php/conf.d/20-xdebug.ini ] && exit 0 \ || (cp /usr/local/etc/php/conf.d/20-xdebug.ini.disabled /usr/local/etc/php/conf.d/20-xdebug.ini && kill -USR2 1)" $ > docker-compose exec php-fpm php -v PHP 7.4.6 (cli) (built: May 15 2020 01:43:37) ( NTS ) Copyright (c) The PHP Group Zend Engine v3.4.0, Copyright (c) Zend Technologies with Xdebug v2.9.6, Copyright (c) 2002-2020, by Derick Rethans $ > make debug-stop docker-compose exec -T -u root php-fpm sh -c "[ -e /usr/local/etc/php/conf.d/20-xdebug.ini ] \ && rm /usr/local/etc/php/conf.d/20-xdebug.ini && kill -USR2 1" $ > docker-compose exec php-fpm php -v PHP 7.4.6 (cli) (built: May 15 2020 01:43:37) ( NTS ) Copyright (c) The PHP Group Zend Engine v3.4.0, Copyright (c) Zend Technologies $ > make debug-start docker-compose exec -T -u root php-fpm sh -c "[ -e /usr/local/etc/php/conf.d/20-xdebug.ini ] && exit 0 \ || (cp /usr/local/etc/php/conf.d/20-xdebug.ini.disabled /usr/local/etc/php/conf.d/20-xdebug.ini && kill -USR2 1)" $ > docker-compose exec php-fpm php -v PHP 7.4.6 (cli) (built: May 15 2020 01:43:37) ( NTS ) Copyright (c) The PHP Group Zend Engine v3.4.0, Copyright (c) Zend Technologies with Xdebug v2.9.6, Copyright (c) 2002-2020, by Derick Rethans ``` -
Zayon revised this gist
Jun 21, 2020 . 1 changed file with 4 additions and 3 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -19,10 +19,11 @@ RUN apk add --no-cache $PHPIZE_DEPS \ *docker-compose.override.yaml* ```docker-compose.override.yaml version: xx services: php-pfm: environment: XDEBUG_CONFIG: idekey=PHPSTORM remote_host=172.23.0.1 remote_port=10000 ``` Remote host is `host.docker.internal` on mac and windows. -
Zayon created this gist
Jun 21, 2020 .There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,45 @@ # Xdebug with Docker *Dockerfile* ``` FROM production as dev USER root RUN apk add --no-cache $PHPIZE_DEPS \ && pecl install xdebug-2.9.0 \ && echo "zend_extension=/usr/local/lib/php/extensions/no-debug-non-zts-20190902/xdebug.so" > /usr/local/etc/php/conf.d/20-xdebug.ini.disabled \ && echo "xdebug.default_enable=1" >> /usr/local/etc/php/conf.d/20-xdebug.ini.disabled \ && echo "xdebug.remote_enable=1" >> /usr/local/etc/php/conf.d/20-xdebug.ini.disabled \ && echo "xdebug.remote_autostart=0" >> /usr/local/etc/php/conf.d/20-xdebug.ini.disabled \ && echo "xdebug.remote_connect_back=1" >> /usr/local/etc/php/conf.d/20-xdebug.ini.disabled \ && echo "xdebug.profiler_enable=0" >> /usr/local/etc/php/conf.d/20-xdebug.ini.disabled ``` *docker-compose.override.yaml* ```docker-compose.override.yaml version: xx services: php-pfm: environment: XDEBUG_CONFIG: idekey=PHPSTORM remote_host=172.23.0.1 remote_port=10000 ``` Remote host is `host.docker.internal` on mac and windows. On linux use `docker inspect <container> | grep Gateway` to find the host ip. ```Makefile .PHONY: debug-start debug-start: ## Enable xdebug ifneq ($(CI), true) docker-compose exec -T -u root php-fpm sh -c "[ -e /usr/local/etc/php/conf.d/20-xdebug.ini ] && exit 0 \ || (mv /usr/local/etc/php/conf.d/20-xdebug.ini.disabled /usr/local/etc/php/conf.d/20-xdebug.ini && kill -USR2 1)" endif .PHONY: debug-stop debug-stop: ## Disable xdebug ifneq ($(CI), true) docker-compose exec -T -u root php-fpm sh -c "[ -e /usr/local/etc/php/conf.d/20-xdebug.ini.disabled ] && exit 0 \ || (mv /usr/local/etc/php/conf.d/20-xdebug.ini /usr/local/etc/php/conf.d/20-xdebug.ini.disabled && kill -USR2 1)" endif ```