Skip to content

Commit 381434a

Browse files
committed
initial xdebug additions
1 parent 598dbe1 commit 381434a

File tree

4 files changed

+42
-1
lines changed

4 files changed

+42
-1
lines changed

Dockerfile

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ RUN GPG_KEYS=B0F4253373F8F6F510D42178520A9993A1C052F8 \
5858
&& addgroup -S nginx \
5959
&& adduser -D -S -h /var/cache/nginx -s /sbin/nologin -G nginx nginx \
6060
&& apk add --no-cache --virtual .build-deps \
61+
autoconf \
6162
gcc \
6263
libc-dev \
6364
make \
@@ -149,6 +150,7 @@ RUN echo @testing http://nl.alpinelinux.org/alpine/edge/testing >> /etc/apk/repo
149150
openssl-dev \
150151
ca-certificates \
151152
dialog \
153+
autoconf \
152154
gcc \
153155
musl-dev \
154156
linux-headers \
@@ -168,6 +170,7 @@ RUN echo @testing http://nl.alpinelinux.org/alpine/edge/testing >> /etc/apk/repo
168170
--with-jpeg-dir=/usr/include/ && \
169171
#curl iconv session
170172
docker-php-ext-install pdo_mysql pdo_sqlite mysqli mcrypt gd exif intl xsl json soap dom zip opcache && \
173+
pecl install xdebug && \
171174
docker-php-source delete && \
172175
mkdir -p /etc/nginx && \
173176
mkdir -p /var/www/app && \
@@ -181,7 +184,7 @@ RUN echo @testing http://nl.alpinelinux.org/alpine/edge/testing >> /etc/apk/repo
181184
pip install -U pip && \
182185
pip install -U certbot && \
183186
mkdir -p /etc/letsencrypt/webrootauth && \
184-
apk del gcc musl-dev linux-headers libffi-dev augeas-dev python-dev
187+
apk del gcc musl-dev linux-headers libffi-dev augeas-dev python-dev autoconf
185188
# ln -s /usr/bin/php7 /usr/bin/php
186189

187190
ADD conf/supervisord.conf /etc/supervisord.conf

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ For more detailed examples and explanations please refer to the documentation.
5858
- [Setup](https://github.com/ngineered/nginx-php-fpm/blob/master/docs/lets_encrypt.md#setup)
5959
- [Renewal](https://github.com/ngineered/nginx-php-fpm/blob/master/docs/lets_encrypt.md#renewal)
6060
- [PHP Modules](https://github.com/ngineered/nginx-php-fpm/blob/master/docs/php_modules.md)
61+
- [Xdebug](https://github.com/ngineered/nginx-php-fpm/blob/master/docs/xdebug.md)
6162
- [Logging and Errors](https://github.com/ngineered/nginx-php-fpm/blob/master/docs/logs.md)
6263

6364
## Guides

docs/xdebug.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
## Install PHP Modules
2+
Xdebug comes pre-installed. To enable xdebug you need to add a couple environment variables:
3+
4+
- `ENABLE_XDEBUG=1` This will add the xdebug.ini to your php extensions
5+
- `XDEBUG_CONFIG=remote_host=you.local.ip.here` Sets an xdebug remote host environment var. This is usually your actual local computers IP.
6+
- `PHP_IDE_CONFIG=serverName=NameUsedInPhpStormServerConfig` This is an example of how to use this in PhpStorm. You configure a server in php storm with a name, set that in this var.

scripts/start.sh

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,37 @@ if [ ! -z "$PHP_UPLOAD_MAX_FILESIZE" ]; then
122122
sed -i "s/upload_max_filesize = 100M/upload_max_filesize= ${PHP_UPLOAD_MAX_FILESIZE}M/g" /usr/local/etc/php/conf.d/docker-vars.ini
123123
fi
124124

125+
# Enable xdebug
126+
XdebugFile='/usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini'
127+
if [[ "$ENABLE_XDEBUG" == "1" ]] ; then
128+
if [ -f $XdebugFile ]; then
129+
echo "Xdebug enabled"
130+
else
131+
echo "Enabling xdebug"
132+
echo "If you get this error, you can safely ignore it: /usr/local/bin/docker-php-ext-enable: line 83: nm: not found"
133+
docker-php-ext-enable xdebug
134+
# see if file exists
135+
if [ -f $XdebugFile ]; then
136+
# See if file contains xdebug text.
137+
if grep -q xdebug.remote_enable "$XdebugFile"; then
138+
echo "Xdebug already enabled... skipping"
139+
else
140+
echo "zend_extension=$(find /usr/local/lib/php/extensions/ -name xdebug.so)" > $XdebugFile # Note, single arrow to overwrite file.
141+
echo "xdebug.remote_enable=1 " >> $XdebugFile
142+
echo "xdebug.remote_log=/tmp/xdebug.log" >> $XdebugFile
143+
echo "xdebug.remote_autostart=false " >> $XdebugFile # I use the xdebug chrome extension instead of using autostart
144+
# NOTE: xdebug.remote_host is not needed here if you set an environment variable in docker-compose like so `- XDEBUG_CONFIG=remote_host=192.168.111.27`.
145+
# you also need to set an env var `- PHP_IDE_CONFIG=serverName=docker`
146+
fi
147+
fi
148+
fi
149+
else
150+
if [ -f $XdebugFile ]; then
151+
echo "Disabling Xdebug"
152+
rm $XdebugFile
153+
fi
154+
fi
155+
125156
if [ ! -z "$PUID" ]; then
126157
if [ -z "$PGID" ]; then
127158
PGID=${PUID}

0 commit comments

Comments
 (0)