PHPUnit-这个版本的PHPUnit需要PHP 5.6;强烈建议使用最新版本的PHP-OSX 10.11


PHPUnit - This version of PHPUnit requires PHP 5.6; using the latest version of PHP is highly recommended - OSX 10.11

我使用的是MAC OS X El Capitan(10.11.1版)。

我使用以下命令安装了PHPint:

brew install homebrew/php/phpunit

当我在终端中键入which phpunit时,它输出:

/usr/local/bin/phpunit

但当我运行phpunit /pathto/file.php时,它给了我一个错误:

分析错误:分析错误,应为'&'' or"变量(T_variable)"'在里面phar:///usr/local/Cellar/phpunit/5.0.0/libexec/phpunit-5.0.0.phar/phar/phpunit-mock-objects/Framework/MockObject/Builder/InvocationMocker.php在线82

所以我所做的是使用以下命令再次安装phpunit:

curl https://phar.phpunit.de/phpunit.phar -o phpunit.phar
chmod +x phpunit.phar
mv phpunit.phar /usr/local/bin/phpunit

然后当我尝试使用phpunit --version时,它会说:

This version of PHPUnit requires PHP 5.6; using the latest version of PHP is highly recommended.

然后我做了:

curl -s http://php-osx.liip.ch/install.sh | bash -s 5.6

当我运行phpinfo()时,它说我的PHP版本是5.6.10。但我再次尝试键入phpunit --version,相同:

This version of PHPUnit requires PHP 5.6; using the latest version of PHP is highly recommended.

经过一些研究,我发现这可能是因为我安装了2个PHPUnit,所以我尝试使用删除PHPUnit

brew uninstall phpunit 

它很成功,然后我再次尝试phpunit --version,但仍然存在PHP版本问题。

此外,如果我再次尝试执行brew uninstall phpunit,它将显示一条消息:

Error: No such keg: /usr/local/Cellar/phpunit

更新

当我键入时

php --version在终端输出

PHP 5.5.29 (cli) (built: Sep  9 2015 00:26:40) 
Copyright (c) 1997-2015 The PHP Group
Zend Engine v2.5.0, Copyright (c) 1998-2015 Zend Technologies

所以我想php版本仍然是5.5.29。我也重新启动了apaches。

您需要确保执行新安装的php命令,而不是默认的命令。

将正确的php二进制文件所在的文件夹作为第一项添加到$PATH环境变量中。

我遇到了同样的问题。不使用酿造。只是在Mac上安装最新的PHP(目前为7)。阅读此处:https://coolestguidesontheplanet.com/upgrade-php-on-osx/

我用过:

curl -s http://php-osx.liip.ch/install.sh | bash -s 7.0

这需要很长时间,但它会告诉你它安装在哪里。对我来说,它是:

/usr/local/php5-7.0.12-20161101-102255/bin/php

我刚刚将其添加到我的~/.bash_profile中,并使用source刷新。现在命令行看到了正确的版本,PHPUnit很高兴。