Bash | Tutorials | Development

David Carr

Switching between PHP versions with Homebrew

With Homebrew it's possible to have multiple versions of PHP installed at once, to switch which version is active unlink the current version and link the desired version. 

Switch from 7.4 to 7.3

brew unlink php@7.4 && brew link --force --overwrite php@7.3

Switch from 7.3 to 7.4

brew unlink php@7.3 && brew link --force --overwrite php@7.4

Since you may want to do this frequently it's more convenient to create a function to do this.

Create a function to your bash/zshrc profile

switchphp() {
    brew unlink php && brew link --force --overwrite php@$1
}

This will unlink PHP and relink to the specified version.

Usage:

switch to PHP 7.4 

switchphp 7.4

switch to PHP 7.3

switchphp 7.3

 

Domains are often purchased from multiple providers, keeping track of where a domain is and its DNS settings can be tricky. Domain Mapper solves this by listing all your domains in one place. View your DNS settings and receive reminders to renew your domains. Try it today.

Support my work by donating with PayPal.

Subscribe to my newsletter

Subscribe and get my books and product announcements.

© 2009 - 2021 DC Blog. All code MIT license. All rights reserved.