Created
June 17, 2016 17:50
-
-
Save benharold/1817a24213b68b948612890391949204 to your computer and use it in GitHub Desktop.
Bash script to toggle xdebug on/off on Mac OS X running PHP installed from Homebrew
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
#!/bin/bash | |
XDEBUG_INI_PATH="/usr/local/etc/php/7.0/conf.d/ext-xdebug.ini" | |
function turn_off { | |
`sed -i '' 's/^zend_extension/#zend_extension/g' $XDEBUG_INI_PATH` | |
} | |
function turn_on { | |
`sed -i '' 's/^#zend_extension/zend_extension/g' $XDEBUG_INI_PATH` | |
} | |
CURRENT=`cat $XDEBUG_INI_PATH | grep xdebug.so` | |
if [[ $CURRENT =~ ^#zend_extension ]]; | |
then | |
echo 'Xdebug is currently off' | |
CHANGE_TO='on' | |
else | |
echo 'Xdubug is currently on' | |
CHANGE_TO='off' | |
fi | |
if [[ ${1+x} ]]; | |
then | |
if [[ ! $1 =~ ^o(n|ff)$ ]]; | |
then | |
echo "Invalid argument: $1. Valid arguments are \`on\` and \`off\`."; | |
else | |
echo "Turning xdebug $1"; | |
eval turn_${1} | |
fi | |
else | |
echo "Turning xdebug $CHANGE_TO" | |
eval turn_${CHANGE_TO} | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment