Skip to content

Instantly share code, notes, and snippets.

@connordavison
Last active January 18, 2017 10:55
Show Gist options
  • Select an option

  • Save connordavison/51ef74d19389c5c3adcd306a743cb772 to your computer and use it in GitHub Desktop.

Select an option

Save connordavison/51ef74d19389c5c3adcd306a743cb772 to your computer and use it in GitHub Desktop.
Toggle Xdebug
#!/bin/bash
XDEBUG='zend_extension.*=.*xdebug'
function xdebug_on {
if grep -q "^;$XDEBUG" $1; then
echo "Enabling Xdebug $1"
cat $1 | sudo sed -i.bak "s|^;\($XDEBUG\)|\1|g" $1
fi
}
function xdebug_off {
if grep -q "^$XDEBUG" $1; then
echo "Disabling Xdebug in $1"
cat $1 | sudo sed -i.bak "s|^\($XDEBUG\)|;\1|g" $1
fi
}
case "$1" in
on) ;;
off) ;;
*) echo "Usage: xdebug on|off"
echo
echo "N.B.: update the default mlocate.db before this command, and"
echo "restart apache afterwards."
exit 1 ;;
esac
for INI in $(locate php.ini xdebug.ini | grep -v \.bak\$); do
xdebug_$1 $INI
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment