Merge pull request #158 from shikorism/feature/xdebug-for-linux

Linux+Dockerな開発環境でxdebugが使えるようにコールバック先IPアドレスの設定を調整
This commit is contained in:
shibafu 2019-03-19 22:45:43 +09:00 committed by GitHub
commit 8e161252a7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 1 deletions

View File

@ -3,6 +3,15 @@ set -e
if [[ "$APP_DEBUG" == "true" ]]; then
export PHP_INI_SCAN_DIR=":/usr/local/etc/php/php.d"
php -r "if (gethostbyname('host.docker.internal') === 'host.docker.internal') exit(1);" &> /dev/null && :
if [[ $? -eq 0 ]]; then
# Docker for Windows/Mac
export PHP_XDEBUG_REMOTE_HOST='host.docker.internal'
else
# Docker for Linux
export PHP_XDEBUG_REMOTE_HOST=$(cat /etc/hosts | awk 'END{print $1}' | sed -r -e 's/[0-9]+$/1/g')
fi
fi
exec docker-php-entrypoint "$@"

View File

@ -1,4 +1,4 @@
; Dockerでのデバッグ用設定
zend_extension=xdebug.so
xdebug.remote_enable=true
xdebug.remote_host=host.docker.internal
xdebug.remote_host=${PHP_XDEBUG_REMOTE_HOST}