Skip to content

Instantly share code, notes, and snippets.

@maurotdo
Created May 23, 2013 11:32
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save maurotdo/5635445 to your computer and use it in GitHub Desktop.
Save maurotdo/5635445 to your computer and use it in GitHub Desktop.
Simple bash script to turn on & off Xdebug extension Based on homebrewed php-xdebug extension
#!/bin/bash
#
# Script to turn xdebug on and off
# Permission to copy and modify is granted under the MIT license
# Last revised 2013-05-23
# Mauro Maggi <maurotdo (at) gmail (dot) com>
PHP=$(which php)
BREW=$(which brew)
XDEBUG=$($PHP -i | grep -i xdebug | grep -i enabled)
INI=$($BREW info php53-xdebug | grep "xdebug.ini was created" | cut -d " " -f4)
if [ -z "$XDEBUG" ]; then
echo "Xdebug is OFF"
else
echo "Xdebug is ON"
fi
if [ "$1" != "on" -a "$1" != "off" ]; then
echo "Usage: xdebug { on | off }"
exit 2
fi
if [ -z "$INI" ]; then
echo "Cannot detect xdebug.ini location";
exit 1;
fi
echo "Found xdebug.ini at $INI"
echo -n "Turning $1 Xdebug ... "
if [ "off" == "$1" ]; then
sed -i" " "s/^/;/g" "$INI"
elif [ "on" == "$1" ]; then
sed -i" " "s/^;*//g" "$INI"
fi
echo "done"
echo
echo "Remember to restart Apache if you're debugging in browser"
echo
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment