Skip to content

Instantly share code, notes, and snippets.

@cviebrock
Created April 17, 2018 15:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cviebrock/ae22d3ff547f6c1e2ccfee09d4bc8c1e to your computer and use it in GitHub Desktop.
Save cviebrock/ae22d3ff547f6c1e2ccfee09d4bc8c1e to your computer and use it in GitHub Desktop.
Helper to switch between brew versions of PHP
#!/usr/bin/env bash
CX="\033[0m"
CR="\033[31m"
CG="\033[32m"
CY="\033[33m"
FULL_VER=`php -r 'echo phpversion();'`
VER=`php -r 'echo phpversion();' | cut -d '.' -f1,2`
echo -e "${CY}Current PHP version:${CX} ${FULL_VER}";
if [ "$VER" == "5.6" ]; then
(brew unlink php@5.6 && brew link php@7.2) >/dev/null
else
(brew unlink php@7.2 && brew link --force php@5.6) >/dev/null
fi
NEW_VER=`php -r 'echo phpversion();'`
echo -e "${CG}New PHP version:${CX} ${NEW_VER}";
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment