How to switch between PHP versions on Mac OS X using homebrew

I use docker for all the projects, but the other day I needed to run a composer command in my host machine to install a Drupal distribution which is not compatible with PHP 8.0, so I needed to switch the PHP version. And the steps to do so are:

  1. Install homebrew: https://docs.brew.sh/Installation
  2. Install the Brew PHP switcher script, using: brew install brew-php-switcher
  3. Switch to the version needed, in this example is 7.4: brew-php-switcher 7.4
    1. You will need to install the version of PHP first: brew install php@7.4

Posted

in

by

Tags: