Mac下安装了多个版本的php,有php5.6,php5.5,php7.1,经常系统升级或者什么故障下就凌乱了。
我在fpm下是php7.1的,今天在执行单元测试的时候,发现cli下又变成5.5的了。
尝试了下
brew link php71
发现当前已经是这样的了。
然后使用命令查看了下
brew info php55
有这么一句
✩✩✩✩ PHP CLI ✩✩✩✩
If you wish to swap the PHP you use on the command line, you should add the following to ~/.bashrc, ~/.zshrc, ~/.profile or your shell's equivalent configuration file:
export PATH="$(brew --prefix homebrew/php/php55)/bin:$PATH"
执行命令
export PATH="$(brew --prefix homebrew/php/php71)/bin:$PATH"
再次查看了下版本
php -v
成功了。
其它方法
sudo vim ~/.bash_profile
export PATH="/usr/local/Cellar/php/7.3.7/bin:$PATH"
source ~/.bash_profile