Skip to content

Instantly share code, notes, and snippets.

@proudlygeek
Forked from maurotdo/xdebug.sh
Created April 28, 2014 15:10
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 proudlygeek/11374973 to your computer and use it in GitHub Desktop.
Save proudlygeek/11374973 to your computer and use it in GitHub Desktop.
#!/bin/bash
#
# Script to turn xdebug on and off
# Permission to copy and modify is granted under the MIT license
# Last revised 2014-03-07
# Mauro Maggi <maurotdo (at) gmail (dot) com>
PHP=$(which php)
XDEBUG=$($PHP -i | grep -i xdebug | grep -i enabled)
INI=$($PHP -i | grep "xdebug.ini")
echo "Found xdebug.ini at $INI"
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 -n "Turning $1 Xdebug ... "
if [ "off" == "$1" ]; then
sed --in-place --follow-symlinks "s/^/;/g" "$INI"
elif [ "on" == "$1" ]; then
sed --in-place --follow-symlinks "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