在 Mac Catalina 上安装和配置新的 php 版本

Install and configure new php version on Mac Catalina

当我得到 mac 时,它已经安装了 php 7.3。我用 Brew 安装了新版本的 php 到 /usr/local/Cellar/php/7.4.9/bin/php 并编辑了 ~/bash_profile,我在其中添加了

export PATH="/usr/local/Cellar/php/7.4.9/bin:$PATH"
export PATH="/usr/local/Cellar/php/7.4.9/sbin:$PATH"

然后source .bash_profile。它适用于当前终端 window,但其他终端 windows 仍在旧 PHP 版本 /usr/bin/php 上,即使在重新启动后也是如此。甚至 PhpStorm 中的插件也声称 php 版本较旧。有帮助吗?

您可以尝试以下方法

  1. brew unlink php@7.3
  2. brew link php@7.4 --force --overwrite
  3. brew services start php@7.4