How to upgrade your macOS PHP version to php8 (Homebrew)
Hello everyone,
Today will be going over the process of upgrading your macOS PHP to php8.
This is a diversion from my normal programming language posts decided to post it here to help you in case you also end up with such a problem regularly.
To update your PHP this article has an assumption that you have already installed homebrew and you have some version of PHP that you are using on your MacBook.
If you don’t have homebrew install please visit this page ( https://brew.sh/ )to follow steps in doing so.
Let’s continue with the upgrade
Start by making sure brew is up-to-date:
brew update
Now we upgrade PHP We will be using ( shivammathur/php ) as it’s the most recommended way to do so using homebrew
brew tap shivammathur/php
brew install shivammathur/php/php@8.0
To switch between versions, use the following command:
brew link --overwrite --force php@8.0
Next steps
Check the current version by running php -v
:
php -v
Restart Nginx or Apache:
sudo nginx -s reloadsudo apachectl restart
And make sure that your local web server also uses PHP 8 by visiting this script:
# index.php, accessible to your web serverphpinfo();
The version should show 8.0.x
.
Hope these simple steps help you.
Before you go… Thanks for reading the article! If you enjoyed it, please don’t forget to show your appreciation by clicking 👏 below!
Any questions or comments hit me up on
Mail: epmnzava@gmail.com
Twitter: https://twitter.com/epmnzava
Github: https://github.com/dbrax
Until next time cheers