您的位置:首页 > 编程语言 > PHP开发

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

2017-08-29 22:25 991 查看
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命令即可。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息