On MAC if you are running the php command in the terminal and getting the php: command not found then you can try the following steps to solve that:
zshrc
Open the .zshrc file by running the following command:
nano ~/.zshrc
Do the following steps in that file:
- Paste the export PATH=”/opt/homebrew/opt/php@7.4/bin:$PATH” line in that end of that file.
- Hit CTRL + O
- Hit CTRL + Enter Key
- Hit CTRL + X

Close the terminal and restart it to test php command now.
bashrc
Open the .bashrc file by running the following command:
nano ~/.bashrc
Do the following steps in that file:
- Paste the export PATH=”/opt/homebrew/opt/php@7.4/bin:$PATH” line in that file.
- Hit CTRL + O
- Hit CTRL + Enter Key
- Hit CTRL + X

Close the terminal and restart it to test php command now.
bash_profile
Open the .bash_profile file by running the following command:
nano ~/.bash_profile
Do the following steps in that file:
- Paste the export PATH=”/opt/homebrew/opt/php@7.4/bin:$PATH” line in that end of that file.
- Hit CTRL + O
- Hit CTRL + Enter Key
- Hit CTRL + X

Close the terminal and restart it to test php command now.
php command should work now and php-v will give you the following output
php -v
PHP 7.4.29 (cli) (built: Apr 14 2022 11:36:10) ( NTS )