Last active
August 31, 2021 10:59
-
-
Save fideloper/d3d0d0add6d37bec050a8277e51da459 to your computer and use it in GitHub Desktop.
Enable/Disable xDebug depending on env.
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 characters
#!/usr/bin/env bash | |
### | |
# A CMD or ENTRYPOINT script for a Dockerfile to use to start a Nginx/PHP-FPM | |
# | |
# For more details, see 🐳 https://shippingdocker.com | |
## | |
if [ ! "production" == "$APP_ENV" ] && [ ! "prod" == "$APP_ENV" ]; then | |
# Enable xdebug | |
## FPM | |
ln -sf /etc/php/7.0/mods-available/xdebug.ini /etc/php/7.0/fpm/conf.d/20-xdebug.ini | |
## CLI | |
ln -sf /etc/php/7.0/mods-available/xdebug.ini /etc/php/7.0/cli/conf.d/20-xdebug.ini | |
else | |
# Disable xdebug | |
## FPM | |
if [ -e /etc/php/7.0/fpm/conf.d/20-xdebug.ini ]; then | |
rm -f /etc/php/7.0/fpm/conf.d/20-xdebug.ini | |
fi | |
## CLI | |
if [ -e /etc/php/7.0/cli/conf.d/20-xdebug.ini ]; then | |
rm -f /etc/php/7.0/cli/conf.d/20-xdebug.ini | |
fi | |
fi | |
# Config /etc/php/7.0/mods-available/xdebug.ini | |
# to correctly set the remote_host to your host computer's IP address | |
sed -i "s/xdebug\.remote_host\=.*/xdebug\.remote_host\=$XDEBUG_HOST/g" /etc/php/7.0/mods-available/xdebug.ini | |
# start supervisord, which | |
# in turn will start Nginx/PHP-FPM | |
/usr/bin/supervisord |
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 characters
zend_extension=xdebug.so | |
xdebug.remote_enable=1 | |
xdebug.remote_handler=dbgp | |
xdebug.remote_port=9000 | |
xdebug.remote_autostart=1 | |
xdebug.remote_connect_back=0 | |
xdebug.idekey=docker | |
; This IP address will get changed | |
; dynamically when the container starts | |
xdebug.remote_host=192.168.1.2 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
if someone wants the
XDEBUG_HOST
on your Linux machine, try this out to get the host address: https://medium.com/@sirajul.anik/docker-for-linux-localhost-docker-connect-to-host-machine-from-a-docker-container-in-linux-fa42b00f161e