Created
October 12, 2023 05:05
-
-
Save ananth-iyer/cc45380c5f722aedd35a3e9a40ed8c35 to your computer and use it in GitHub Desktop.
Bash scripts to enable & disable xdebug in FPM/CLI for local development. Inspired by https://medium.com/@kayintveen/easily-enable-and-disable-xdebug-275f7edc5bad
This file contains 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 | |
if ! test -f /etc/php/8.1/fpm/conf.d/20-xdebug.ini && ! test -f /etc/php/8.1/cli/conf.d/20-xdebug.ini; then | |
echo " | |
# | |
# Xdebug is not enabled | |
# | |
"; | |
/usr/bin/php8.1 -v | |
exit | |
fi | |
echo " | |
# | |
# Disabling Xdebug... | |
# | |
"; | |
sudo rm -f /etc/php/8.1/fpm/conf.d/20-xdebug.ini | |
sudo rm -f /etc/php/8.1/cli/conf.d/20-xdebug.ini | |
sudo service php8.1-fpm restart | |
/usr/bin/php8.1 -v | |
echo " | |
# | |
# Remember to execute 'unset XDEBUG_CONFIG' if you are debugging from the command line | |
# | |
"; |
This file contains 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 | |
if test -f /etc/php/8.1/fpm/conf.d/20-xdebug.ini && test -f /etc/php/8.1/cli/conf.d/20-xdebug.ini; then | |
echo " | |
# | |
# Xdebug is already enabled | |
# | |
"; | |
/usr/bin/php8.1 -v | |
exit | |
fi | |
echo " | |
# | |
# Enabling Xdebug... | |
# | |
"; | |
sudo ln -s /etc/php/8.1/mods-available/xdebug.ini /etc/php/8.1/fpm/conf.d/20-xdebug.ini | |
sudo ln -s /etc/php/8.1/mods-available/xdebug.ini /etc/php/8.1/cli/conf.d/20-xdebug.ini | |
sudo service php8.1-fpm restart | |
/usr/bin/php8.1 -v | |
echo " | |
# | |
# Remember to execute 'export XDEBUG_CONFIG=\"idekey=PHPSTORM\"' if you are debugging from the command line | |
# | |
"; |
This file contains 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.mode=debug | |
xdebug.remote_enable=0 | |
xdebug.remote_autostart=0 | |
xdebug.profiler_enable=0 | |
xdebug.remote_port=9000 | |
xdebug.max_nesting_level=300 | |
xdebug.start_with_request=yes |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment