Useful Snippets


This blog is used to collect useful snippets related to Linux, PHP, MySQL and more. Feel free to post comments with improvements or questions!

Are your smart devices spying on you? Make better purchasing choices and find products that respect your privacy at

RSS Latest posts from my personal blog

Most viewed posts

Subscribe to RSS feed

Switch between different PHP versions on Mac OSX using Homebrew

Stanislav KhromovStanislav Khromov

There are multiple fancy scripts out there for managing PHP versions, but here I will show you how you can get the same result with just Homebrew, which you probably already have installed.

Install different PHP versions:

brew install php@7.2
brew install php@7.3
brew install php@7.4
brew install php@8.0

Let’s say you want version 8.0, simply run:

brew unlink php && brew link php@8.0


PHP 8.0.2 (cli) (built: Feb  4 2021 17:58:53) ( NTS )
Copyright (c) The PHP Group
Zend Engine v4.0.2, Copyright (c) Zend Technologies
    with Zend OPcache v8.0.2, Copyright (c), by Zend Technologies

Simply repeat the unlink/link command every time you want to switch version.

These commands have been tested on OSX Catalina but should also work for earlier versions of OSX.


Web Developer at Aftonbladet (Schibsted Media Group)
Any opinions on this blog are my own and do not reflect the views of my employer.
Twitter Profile
Visit my other blog

Comments 0
There are currently no comments.