Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

owiesnama's avatar

Switching PHP versions on mac

Hi there, I'm trying to switch to an older version than the pre-installed version with no luck. I've tried to link the old version using brew

brew unlink [email protected] && brew link --force [email protected]

and that's seems to go fine

Unlinking /usr/local/Cellar/[email protected]/7.2.34_4.reinstall.reinstall... 14 symlinks removed.
Linking /usr/local/Cellar/[email protected]/7.2.34_4.reinstall.reinstall... 14 symlinks created.

If you need to have this software first in your PATH instead consider running:
  echo 'export PATH="/usr/local/opt/[email protected]/sbin:$PATH"' >> ~/.zshrc

but when I check again for the php version it still uses the php7.3 which is pre-installed and I cann't use it with valet either

➜  ~ php -v
WARNING: PHP is not recommended
PHP is included in macOS for compatibility with legacy software.
Future versions of macOS will not include PHP.
PHP 7.3.24-(to be removed in future macOS) (cli) (built: May  8 2021 09:40:37) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.3.24, Copyright (c) 1998-2018 Zend Technologies
0 likes
3 replies
AlexElementarteilchen's avatar

Maybe you have it set it in your zsh path?

I had recently the same problem: Changed php version with brew and valet and everything was set correctly but it still used the old version on the command line.

Checked my path settings and there it was: absolute path to the old php binary. Once I removed that, the new version was correctly loaded.

2 likes

Please or to participate in this conversation.