Skip to content

Instantly share code, notes, and snippets.

@besrabasant
Last active April 20, 2019 04:01
Show Gist options
  • Save besrabasant/4415fa7881df28af93b1dd858bacd18a to your computer and use it in GitHub Desktop.
Save besrabasant/4415fa7881df28af93b1dd858bacd18a to your computer and use it in GitHub Desktop.
XDebug Toggler
#!/bin/bash
# Simple script to enable or disable the xdebug extension
# Note that xargs removes whitespace
PHPINIDIR=`php --ini | head -1 | cut -d ":" -f 2 | xargs echo`
PHPDIR=${PHPINIDIR//"/cli"/}
case $1 in
on)
[ -f $PHPDIR/mods-available/xdebug.ini ] && ln -s $PHPDIR/mods-available/xdebug.ini $PHPINIDIR/conf.d/20-xdebug.ini
valet restart
echo "Xdebug is ON"
;;
off)
[ -L $PHPINIDIR/conf.d/20-xdebug.ini ] && rm $PHPINIDIR/conf.d/20-xdebug.ini
valet restart
echo "Xdebug is OFF"
;;
*)
ME=`basename "$0"`
if [ -L $PHPINIDIR/conf.d/20-xdebug.ini ]; then
. $ME off
else
. $ME on
fi
;;
esac
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment