Skip to content

Instantly share code, notes, and snippets.

@rakodev
Last active August 2, 2019 11:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rakodev/b308e59a168039a767b7588ed9318017 to your computer and use it in GitHub Desktop.
Save rakodev/b308e59a168039a767b7588ed9318017 to your computer and use it in GitHub Desktop.
Enable or Disable xdebug with php-fpm
#!/usr/bin/env bash
phpVersion=7.3
if [[ "$1" == "status" ]]; then
if [[ -e /etc/php/${phpVersion}/fpm/conf.d/20-xdebug.ini ]]; then
echo "Xdebug is Enabled";
else
echo "Xdebug is Disabled";
fi
exit 0;
fi
if [[ -e /etc/php/${phpVersion}/fpm/conf.d/20-xdebug.ini ]]; then
# disable xdebug fpm
rm -f /etc/php/${phpVersion}/fpm/conf.d/20-xdebug.ini
# disable xdebug cli
rm -f /etc/php/${phpVersion}/cli/conf.d/20-xdebug.ini
echo "Disable Xdebug";
else
# enable xdebug fpm
ln -sf /etc/php/${phpVersion}/mods-available/xdebug.ini /etc/php/${phpVersion}/fpm/conf.d/20-xdebug.ini
# enable xdebug cli
ln -sf /etc/php/${phpVersion}/mods-available/xdebug.ini /etc/php/${phpVersion}/cli/conf.d/20-xdebug.ini
echo "Enable Xdebug";
fi
# Uncomment this line if you don't use this script in a docker container
#service php${phpVersion}-fpm restart
#!/usr/bin/env bash
# if you use a docker comtainer, you also need this file
# edit the path according to your setup
docker-compose exec php-fpm bash -c './docker/xdebug-on-off.sh '$1
if [[ -z "$1" || "$1" != "status" ]]; then
docker-compose restart php-fpm;
fi
# enable or disable xdebug
# ./xdebug.sh
# check xdebug status
# ./xdebug status
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment