Change php version in mac

Change php version in mac

First you must have installed brew.

 

Run these commands in your terminal

brew install php@7.0

brew install php@7.1

brew install php@7.2

brew install php@7.3

Add this aliases in ~/.zhrc

phpv() {
    valet stop
    brew unlink php@7.0 php@7.1 php@7.2
    brew link --force --overwrite $1
    brew services start $1
    composer global update
    rm -f ~/.config/valet/valet.sock
    valet install
}

alias php70="phpv php@7.0"
alias php71="phpv php@7.1"
alias php72="phpv php"

Related Articles

php artisan tinker

This terminal command provides a REPL (Read-Eval-Print Loop) for PHP with your application’s settings already loaded: php artisan tinker You

SQLSTATE[HY000] [1045] Access denied for user ‘homestead’@’localhost’ (using password: YES)

When I run the command “php artisan migrate” I get the following error message: [PDOException]  SQLSTATE[HY000] [1045] Access denied for

This package requires php <=7.0.27 but your PHP version (7.0.30) does not satisfy that requirement.

At some projects when I tried: php composer install it gives me the following error: – This package requires php