DEV Community

Cover image for Install PHP8, PHP7 on macOS Big Sure
Xun Zhou
Xun Zhou

Posted on

7 1

Install PHP8, PHP7 on macOS Big Sure

Only PHP7.2 through 7.4 are officially supported by Brew, but these have to be build which is pretty slow. For the latest version of PHP, I am going to use the new tap from @shivammahtur as there are many versions pre-built.

➜ brew tap shivammathur/php

# different versions of PHP
➜ brew install shivammathur/php/php@7.4
➜ brew install shivammathur/php/php@8.0
Enter fullscreen mode Exit fullscreen mode

After the successful installation, you are able to find the php.ini for each version of PHP in the following directories:

/usr/local/etc/php/7.4/php.ini
/usr/local/etc/php/8.0/php.ini
Enter fullscreen mode Exit fullscreen mode

or show the php.iniby using the command:

➜ php -i | grep php.ini
Enter fullscreen mode Exit fullscreen mode

switch PHP version

# switch to 7.4
brew unlink php && brew link --overwrite --force php@7.4

# switch to 8.0
brew unlink php && brew link --overwrite --force php@8.0
Enter fullscreen mode Exit fullscreen mode

define the aliases

alias php74="brew unlink php && brew link --overwrite --force php@7.4"
alias php80="brew unlink php && brew link --overwrite --force php@8.0"
Enter fullscreen mode Exit fullscreen mode

then type php74 or php80 to switch php versions.

Please leave your appreciation by commenting on this post!

Of course, only if it was helpful.

Okay, let's go.

Top comments (5)

Collapse
 
naizhao profile image
Sam Ng β€’

Hey fellow macOS user! I've recently discovered something that's been a game-changer for my PHP development: servbay.dev . It's got all versions of PHP, MariaDB, and PostgreSQL, and even throws redis and memcached into the mix.

The best part? You can run multiple versions of PHP instances all at once. Switching between them for debugging and testing is a breeze. A couple of clicks and you're fully set up. Trust me, it's made my PHP dev life a whole lot smoother. Might be worth a shot for you to check it out!

Collapse
 
eshimischi profile image
eshimischi β€’ β€’ Edited

curl -L gist.githubusercontent.com/rhukste... > /usr/local/bin/sphp
chmod +x /usr/local/bin/sphp

sphp 8.0

Collapse
 
vikbert profile image
Xun Zhou β€’ β€’ Edited

hi @eshimischi , thx for sharing and it looks nice

Collapse
 
eshimischi profile image
eshimischi β€’

Welcome!

Collapse
 
meodev profile image
Valentino Menegatti β€’

nice,
in my case:
alias php74="brew unlink php@8.0 && brew link --overwrite --force php@7.4"
alias php80="brew unlink php@7.4 && brew link --overwrite --force php@8.0"

πŸ‘‹ Kindness is contagious

Discover a treasure trove of wisdom within this insightful piece, highly respected in the nurturing DEV Community enviroment. Developers, whether novice or expert, are encouraged to participate and add to our shared knowledge basin.

A simple "thank you" can illuminate someone's day. Express your appreciation in the comments section!

On DEV, sharing ideas smoothens our journey and strengthens our community ties. Learn something useful? Offering a quick thanks to the author is deeply appreciated.

Okay