shivammathur / homebrew-php

:beer: Homebrew tap for PHP 5.6 to 8.4. PHP 8.4 is built nightly.

Home Page:https://github.com/shivammathur/homebrew-php/packages

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Cannot switch between PHP versions

thugic opened this issue · comments

commented

Describe the bug
When trying to switch between versions I only get PHP 7.4

php -v gives me:

➜  ~ php -v
PHP 7.4.27 (cli) (built: Dec 17 2021 00:35:51) ( NTS )
Copyright (c) The PHP Group
Zend Engine v3.4.0, Copyright (c) Zend Technologies
    with Zend OPcache v7.4.27, Copyright (c), by Zend Technologies

If I do:

brew link --force --overwrite php@8.0

I get:

➜  ~ brew link --force --overwrite php@8.0
Warning: Already linked: /usr/local/Cellar/php@8.0/8.0.14
To relink, run:
  brew unlink php@8.0 && brew link --force php@8.0

If I run (as per the README):

➜  ~ brew unlink php@8.0
Unlinking /usr/local/Cellar/php@8.0/8.0.14... 25 symlinks removed.
➜  ~ brew link --overwrite --force shivammathur/php/php@8.0
Linking /usr/local/Cellar/php@8.0/8.0.14... 25 symlinks created.

If you need to have this software first in your PATH instead consider running:
  echo 'export PATH="/usr/local/opt/php@8.0/bin:$PATH"' >> ~/.zshrc
  echo 'export PATH="/usr/local/opt/php@8.0/sbin:$PATH"' >> ~/.zshrc

And then restart the shell, I still get PHP 7.4 ...

Funny enough, if I do:

valet use php@8.0

and then do phpinfo() I see that the webserver is running PHP 8.0

CLI version is still 7.4 though ...

What is the output when you run this echo $PATH

commented
➜  ~ echo $PATH
/usr/local/sbin:/usr/local/opt/php@7.4/sbin:/usr/local/opt/php@7.4/bin: [ ---- ]
commented

@shivammathur thanks for the help: turns out I had the version hard-coded in the .zshrc file. Once I commented that out, and ran php -v it shown the expected version.

Thanks for the valuable input and for your efforts in keeping the project alive.

Cheers.