Created
February 11, 2022 03:46
-
-
Save ahmadrio/b0802beea78dd91903cd1eede89d8f16 to your computer and use it in GitHub Desktop.
Laravel Valet Switch PHP Version
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
# Function switch-php [to version] [from version] | |
# etc: switch-php php@7.1 php@7.4 | |
switch-php() { | |
echo '----> Valet use php version' | |
valet use $1 | |
echo '----> Stop valet' | |
valet stop | |
echo '----> Brew link/unlink php version' | |
# register your php version in your computer | |
brew unlink php@8.1 php@7.4 php@7.2 php@7.1 | |
brew link $1 --force --overwrite | |
echo '----> Brew restart php' | |
brew services restart $1 | |
echo '----> Add export path to file ~/.switch-php' | |
echo -n > ~/.switch-php | |
echo 'export PATH=''"/usr/local/opt/'$1'/bin:$PATH"' >> ~/.switch-php | |
echo 'export PATH=''"/usr/local/opt/'$1'/sbin:$PATH"' >> ~/.switch-php | |
source ~/.switch-php | |
echo '----> Composer global updated' | |
composer global update | |
echo '----> Valet install' | |
valet install | |
echo '----> Sudo brew stop php version' | |
brew services stop $2 | |
echo '----> Valet restart' | |
valet restart | |
echo '----> Show PHP version' | |
php -v | |
echo '----> DONE!' | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment