[TOC] #### 1. 命令行 PHP 版本切换 --- 通过 brew 安装 php ``` brew install php@7.4 brew install php@8.0 ``` 通过 brew 安装 php 后,可以通过 `unlink` 和 `link` 在 PHP 版本之间切换 ``` # 断开链接 php@7.4 brew unlink php@7.4 # 链接到 php@8.0 brew link php@8.0 ``` #### 2. brew-php-switcher --- [https://formulae.brew.sh/formula/brew-php-switcher](https://formulae.brew.sh/formula/brew-php-switcher) brew-php-switcher 是一个 PHP 切换器,用于快速切换 Apache 和 CLI (命令行 PHP 版本) 配置 ``` brew install brew-php-switcher ``` 将命令行行中的 PHP 版本切换到 7.3。-s 参数代表不切换 apache 配置。详情查看: [https://github.com/philcook/php-switcher](https://github.com/philcook/php-switcher) ``` brew-php-switcher 7.3 -s ```