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
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
or show the php.ini
by using the command:
➜ php -i | grep php.ini
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
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"
then type php74
or php80
to switch php versions.
Top comments (4)
curl -L gist.githubusercontent.com/rhukste... > /usr/local/bin/sphp
chmod +x /usr/local/bin/sphp
sphp 8.0
hi @eshimischi , thx for sharing and it looks nice
Welcome!
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"