Installing/Change PHP on your Mac

First, unlink the version you want using the following command

brew unlink php@8.0

Then link your desired version using the following command

brew link php@7.4

Ref: https://daily-dev-tips.com/posts/installing-php-on-your-mac/