Check the current PHP version installed
First check your current version on mac with the below command into your terminal.
PHP 7.3.11 (cli) (built: Jun 5 2020 23:50:40) ( NTS ) Copyright (c) 1997-2018 The PHP Group Zend Engine v3.3.11, Copyright (c) 1998-2018 Zend Technologies
This command allows to know the current version installed on your mac. By default it has been installed by the OS.
Installing new version
Below you must enter the next command into terminal change the word version. e.g:7.4
brew install php@version
Add references to PATH
Now you just need to add it to the PATH of your terminal with the next command, depending of your shell you'll must change the word .zshrc for .bashrc or any other you use:
echo 'export PATH="/firstname.lastname@example.org/bin:$PATH"' >> ~/.zshrc echo 'export PATH="/email@example.com/sbin:$PATH"' >> ~/.zshrc
Check the new version installed
Now check again your current version:
PHP 7.4.13 (cli) (built: Nov 30 2020 14:46:04) ( NTS ) Copyright (c) The PHP Group Zend Engine v3.4.0, Copyright (c) Zend Technologies with Zend OPcache v7.4.13, Copyright (c), by Zend Technologies
That's all Folks
I hope this post has been helpful for you, remember to share this post to help to other or contact me through my social networks and tell me what you think.