Mac OSX使用brew安装旧版本phpunit的方法

brew又称Homebrew,是Mac OSX系统的软件包管理工具,能在Mac中方便安装或卸载软件,类似ubuntu系统的apt-get功能。


常用命令如下:

安装软件
brew install [formula]

卸载软件
brew uninstall [formula]

查看软件
brew search [formula]

升级软件
brew upgrade [formula]

更新brew可支持的软件
brew update


使用brew install安装,会安装最新的版本。

因工作需要,需要安装phpunit,但代码框架不支持最新的phpunit版本,因此需要安装旧版本的phpunit。

1.使用brew安装phpunit

brew install phpunit

安装完后查看版本

phpunit --version
PHPUnit 6.3.0 by Sebastian Bergmann and contributors.

brew install安装的会是最新的版本,而我们需要的是旧版本,因此把此版本卸载。

brew uninstall phpunit



2.更新brew,检查是否存在可安装的旧版本

brew update
Already up-to-date.

更新完后,使用brew search查看可安装的版本

brew search phpunit

homebrew/php/phpunit
homebrew/php/phpunit-skeleton-generator
homebrew/php/phpunit@5.7

发现还支持5.7版本,这个版本代码框架支持,可以使用。


3.安装旧版本

brew install phpunit@5.7
==> Installing phpunit@5.7 from homebrew/php
==> Downloading https://homebrew.bintray.com/bottles-php/phpunit@5.7-5.7.21.sierra.bottle.tar.gz
Already downloaded: /Users/fdipzone/Library/Caches/Homebrew/phpunit@5.7-5.7.21.sierra.bottle.tar.gz
==> Pouring phpunit@5.7-5.7.21.sierra.bottle.tar.gz
  /usr/local/Cellar/phpunit@5.7/5.7.21: 5 files, 2.9MB



4.创建快捷方式

安装完成后,因为不是最新的版本,因此不会自动创建快捷方式,我们需要手动去创建。

phpunit --version
-bash: /usr/local/bin/phpunit: No such file or directory

手动创建快捷方式,使用软链接指向安装的旧版本

ln -s /usr/local/Cellar/phpunit\@5.7/5.7.21/bin/phpunitat57 /usr/local/bin/phpunit

使用快捷方式查看版本,可以看到调用旧版本成功

phpunit --version
PHPUnit 5.7.21 by Sebastian Bergmann and contributors.



使用brew安装旧版本软件,一定要先卸载当前版本的软件,再重新安装。而如果要升级新版本则直接使用brew upgrade命令即可。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值