Uninstall & install new PHP version

Installing (and uninstalling) new PHP version was always a trouble. This time, I found a proper way to handle this.

January 05, 2022

Code 💻

1 min read

brew unlink php@7.4
brew install php
brew link php

You can be specific about which version of php you wish to delete / install.

If brew link php@whatever-version-installed does not work, may need to try:

vi .zshrc

This opens vim editor. We need to add following code to the editor:

export PATH=$PATH:/usr/local/opt/php@8.0/bin


export PATH="/usr/local/opt/php@8.1/bin:$PATH"

We need to source the file to apply new changes permanently.

source .zshrc

Now try:

php -v
which php