Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Xdebug #102

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,13 @@ RUN mkdir /var/www/moodledata && chown www-data /var/www/moodledata && \
mkdir /var/www/phpunitdata && chown www-data /var/www/phpunitdata && \
mkdir /var/www/behatdata && chown www-data /var/www/behatdata && \
mkdir /var/www/behatfaildumps && chown www-data /var/www/behatfaildumps

ARG XDEBUG=0
ARG XDEBUG_VERSION=2.7.2
ARG XDEBUG_PORT=9000
ARG XDEBUG_REMOTE_HOST=docker.for.mac.host.internal
RUN /tmp/setup/xdebug-extension.sh \
-d $XDEBUG \
-v $XDEBUG_VERSION \
-p $XDEBUG_PORT \
-h $XDEBUG_REMOTE_HOST
62 changes: 62 additions & 0 deletions root/tmp/setup/xdebug-extension.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
#!/usr/bin/env bash

set -e

usage() { echo "Usage: $0 -d <debug> -v <Xdebug version> -p <port> -h <remote host>" 1>&2; exit 1; }

while getopts ":d:v:p:h:" o; do
case "${o}" in
d)
DEBUG=${OPTARG}
;;
v)
VERSION=${OPTARG}
;;
p)
PORT=${OPTARG}
;;
h)
REMOTE_HOST=${OPTARG}
;;
*)
usage
;;
esac
done
shift "$((OPTIND-1))"

echo $DEBUG
echo $VERSION
echo $PORT
echo $REMOTE_HOST


if [[ -z $DEBUG ]] || [[ -z $VERSION ]] || [[ -z $PORT ]] || [[ -z $REMOTE_HOST ]]; then
usage
fi

if [ $DEBUG == 1 ]; then

XDEBUG_INI_FILE=/usr/local/etc/php/conf.d/xdebug.ini

# Install Xdebug
echo "Installing Xdebug"
pecl install xdebug-$VERSION
docker-php-ext-enable xdebug

# Adding Xdebug log file
mkdir /var/log/xdebug
touch /var/log/xdebug/xdebug.log
chmod 777 /var/log/xdebug/xdebug.log

# Adding Xdebug INI file
cat <<EOF >> $XDEBUG_INI_FILE
zend_extension=xdebug.so
xdebug.remote_enable=1
xdebug.remote_handler=dbgp
xdebug.remote_mode=req
xdebug.remote_host=$REMOTE_HOST
xdebug.remote_port=$PORT
xdebug.remote_log=/var/log/xdebug/xdebug.log
EOF
fi