1+ #! /usr/bin/env bash
2+
3+ IMAGE_FAMILY=$( docker-image-info family)
4+
5+ case " $IMAGE_FAMILY " in
6+ Alpine)
7+ # Fix php xdebug module [Alpine family]
8+
9+ if [[ -f " /etc/php5/conf.d/xdebug.ini" ]]; then
10+ go-replace --mode=lineinfile \
11+ -s ' ^extension=xdebug.so' -r ' zend_extension=xdebug.so' \
12+ /etc/php5/conf.d/xdebug.ini
13+ fi
14+
15+ if [[ -f " /etc/php7/conf.d/xdebug.ini" ]]; then
16+ go-replace --mode=lineinfile \
17+ -s ' ^extension=xdebug.so' -r ' zend_extension=xdebug.so' \
18+ /etc/php7/conf.d/xdebug.ini
19+ fi
20+
21+ ;;
22+ esac
23+
24+ # Configure xdebug for development
25+ declare -A XDEBUG
26+ XDEBUG[version]=$( php -r " echo phpversion('xdebug');" )
27+
28+ if [[ " $( version-compare " ${XDEBUG[version]} " " 3.0.0" ) " == " <" ]]; then
29+ XDEBUG[remote_enable]=' xdebug.remote_enable = 1'
30+ XDEBUG[remote_connect_back]=' xdebug.remote_connect_back = 1'
31+ XDEBUG[profiler_output_dir]=' xdebug.profiler_output_dir = /tmp/debug'
32+ else
33+ XDEBUG[mode]=' xdebug.mode = debug'
34+ XDEBUG[discover_client_host]=' xdebug.discover_client_host = 1'
35+ XDEBUG[start_with_request]=' xdebug.start_with_request = trigger'
36+ XDEBUG[output_dir]=' xdebug.output_dir = /tmp/debug'
37+ fi
38+
39+ go-replace --mode=lineinfile --regex \
40+ -s ' ^[\s;]*xdebug.idekey[\s]*=' -r ' xdebug.idekey = docker' \
41+ -s ' ^[\s;]*xdebug.cli_color[\s]*=' -r ' xdebug.cli_color = 1' \
42+ -s ' ^[\s;]*xdebug.max_nesting_level[\s]*=' -r ' xdebug.max_nesting_level = 1000' \
43+ -s ' ^[\s;]*xdebug.remote_enable[\s]*=' -r " ${XDEBUG[remote_enable]:- } " \
44+ -s ' ^[\s;]*xdebug.remote_connect_back[\s]*=' -r " ${XDEBUG[remote_connect_back]:- } " \
45+ -s ' ^[\s;]*xdebug.profiler_output_dir[\s]*=' -r " ${XDEBUG[profiler_output_dir]:- } " \
46+ -s ' ^[\s;]*xdebug.mode[\s]*=' -r " ${XDEBUG[mode]:- } " \
47+ -s ' ^[\s;]*xdebug.discover_client_host[\s]*=' -r " ${XDEBUG[discover_client_host]:- } " \
48+ -s ' ^[\s;]*xdebug.start_with_request[\s]*=' -r " ${XDEBUG[start_with_request]:- } " \
49+ -s ' ^[\s;]*xdebug.output_dir[\s]*=' -r " ${XDEBUG[output_dir]:- } " \
50+ -- /opt/docker/etc/php/php.webdevops.ini
0 commit comments