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).
I am using MAC OS X El Capitan (Version 10.11.1).
我使用以下命令安装了PHPUint:
I installed PHPUint using the following command:
brew install homebrew/php/phpunit
当我在终端中键入which phpunit
时,它输出:
When I type which phpunit
in the terminal it outputs:
/usr/local/bin/phpunit
但是当我运行phpunit /pathto/file.php
时,它给了我这个错误:
but when I run phpunit /pathto/file.php
, it gave me this error:
解析错误:解析错误,预期为
'&'' 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行
Parse error: parse error, expecting
'&'' or
"variable (T_VARIABLE)"' in phar:///usr/local/Cellar/phpunit/5.0.0/libexec/phpunit-5.0.0.phar/phar/phpunit-mock-objects/Framework/MockObject/Builder/InvocationMocker.php on line 82
所以我要做的是使用以下命令再次安装了phpunit:
So what I did was I installed phpunit again using these commands:
curl https://phar.phpunit.de/phpunit.phar -o phpunit.phar
chmod +x phpunit.phar
mv phpunit.phar /usr/local/bin/phpunit
然后当我尝试使用phpunit --version
时说:
then when I try to use phpunit --version
it says:
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
,同样是:
When I run phpinfo()
it says my PHP version is 5.6.10
. But again I tried to type phpunit --version
, the same:
This version of PHPUnit requires PHP 5.6; using the latest version of PHP is highly recommended.
经过一番研究,我发现这可能是因为我安装了2个PHPUnit,所以我尝试使用以下方式删除PHPUnit:
After some research I found that’s may be because I have 2 installations of PHPUnit so I tried to remove PHPUnit using:
brew uninstall phpunit
成功,然后我再次尝试
it was successful, then again I tried to phpunit --version
, but still the PHP version issue.
如果我再次尝试执行brew uninstall phpunit
,它也会显示一条消息:
And also if I try to do a brew uninstall phpunit
again, it will show a message:
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.我也重新开始了阿帕奇.
So I guess php version still picks up as 5.5.29 . I restarted apaches also .
推荐答案
您需要确保执行了新安装的php
命令,而不是默认命令.
You need to make sure that the newly installed php
command is executed, not the default one.
将正确的PHP二进制文件所在的文件夹作为第一项添加到$PATH
环境变量.
Add the folder where the correct php binary resides as the first item to the $PATH
environment variable.
这篇关于PHPUnit-此版本的PHPUnit需要PHP 5.6;强烈建议使用最新版本的PHP-OSX 10.11的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!