Uninstall & install new PHP version
I had enough of shenanigans of installing PHP and failing to use it. Hereβs a way I finally got it to work.
January 04, 2022 β’ Code
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
or
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