Skip to content

Instantly share code, notes, and snippets.

@bmadigan
Last active August 9, 2020 17:20
Show Gist options
  • Save bmadigan/b56fc503194fec08f5fd77612ea6dbab to your computer and use it in GitHub Desktop.
Save bmadigan/b56fc503194fec08f5fd77612ea6dbab to your computer and use it in GitHub Desktop.
ZSH Functions
# Switch PHP versions
phpv() {
valet stop
brew unlink php@7.1 php@7.2 php@7.4
brew link --force --overwrite $1
brew services start $1
composer global update
valet install
}
alias php71="phpv php@7.1"
alias php72="phpv php@7.2"
alias php74="phpv php@7.4"
xdebug() {
iniFileLocation="/usr/local/etc/php/7.2/conf.d/ext-xdebug.ini";
currentLine=`cat $iniFileLocation | grep xdebug.so`
if [[ $currentLine =~ ^#zend_extension ]];
then
sed -i -e 's/^#zend_extension/zend_extension/g' $iniFileLocation
echo "xdebug is now active";
else
sed -i -e 's/^zend_extension/#zend_extension/g' $iniFileLocation
echo "xdebug is now inactive";
fi
}
function db {
if [ "$1" = "refresh" ]; then
mysql -uroot -e "drop database $2; create database $2"
elif [ "$1" = "create" ]; then
mysql -uroot -e "create database $2"
elif [ "$1" = "drop" ]; then
mysql -uroot -e "drop database $2"
fi
}
function homestead() {
( cd ~/Homestead && vagrant $* )
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment