Created
March 7, 2014 16:44
-
-
Save maurotdo/9414973 to your computer and use it in GitHub Desktop.
Simple bash script to turn on & off Xdebug extension Based on Ubuntu 13.10 php5-xdebug extension
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
#!/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
Neat script, but a little comma is wrecking my day: Found xdebug.ini at /etc/php.d/xdebug.ini,
INI=$($PHP -i | grep "xdebug.ini"| tr -d ',') did it for me.