Update PHP to 7.4 macOS Catalina with brew

If anyone want to downgrade php from latest 8.1.2 to 7.4 on systems demand, try the below commands with homebrew: Installing PHP 7.4 :

brew install [email protected]
brew services restart php
brew unlink [email protected]
brew link [email protected]
echo 'export PATH="/usr/local/opt/[email protected]/bin:$PATH"' >> ~/.zshrc
echo 'export PATH="/usr/local/opt/[email protected]/sbin:$PATH"' >> ~/.zshrc

Or

export PATH="/usr/local/opt/[email protected]/bin:$PATH"
export PATH="/usr/local/opt/[email protected]/sbin:$PATH" 

try:

brew update
brew upgrade php
php -v
brew services start php

or

brew services restart php

if you use apache server:

sudo apachectl restart

if you use ngnix

sudo nginx -s reload

Edit:

brew unlink [email protected]
brew link [email protected]

Using terminal of MacOS. Don't use terminal in vscode.


You can find my similar answer for [email protected].