PHPUnit (Linux) 的问题 - PHP 致命错误
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/6063045/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Problems with PHPUnit (Linux) - PHP Fatal Error
提问by Johnny
I successfully installed PHPUnit on my desktop PC and decided to have it on my laptop PC, but... then I try to create PHPUnit test Netbeans throws an error "Selected PHPUnit (version ?.?.?) is to old, upgrade it if possible (the minimum version is 3.3.0).".
我在台式电脑上成功安装了 PHPUnit,并决定将它安装在我的笔记本电脑上,但是......然后我尝试创建 PHPUnit 测试 Netbeans 抛出错误“选定的 PHPUnit(版本 ?.?.?)太旧,升级它如果可能(最低版本为 3.3.0)。”。
Of course my PHPUnit version is newer - 3.5.5-2. Where is the problem?
当然,我的 PHPUnit 版本更新了 - 3.5.5-2。问题出在哪儿?
I am using
我在用
- Ubuntu 11.04
- Netbeans 6.9
- PEAR Version: 1.9.1
- PHP Version: 5.3.5-1ubuntu7.2
- Zend Engine Version: 2.3.0
- Ubuntu 11.04
- 网豆 6.9
- 梨版本:1.9.1
- PHP 版本:5.3.5-1ubuntu7.2
- Zend 引擎版本:2.3.0
As I understand the problem is with PHPUnit. When I try to call "phpunit" command in terminal I receive PHP Fatal error:
据我了解,问题出在 PHPUnit 上。当我尝试在终端中调用“phpunit”命令时,我收到 PHP 致命错误:
root@ubuntu:~# phpunit –version
PHP Warning: require_once(PHP/CodeCoverage/Filter.php): failed to open stream: No such file or directory in /usr/bin/phpunit on line 38
PHP Stack trace:
PHP 1. {main}() /usr/bin/phpunit:0
PHP Fatal error: require_once(): Failed opening required 'PHP/CodeCoverage/Filter.php' (include_path='.:/usr/share/php:/usr/share/pear') in /usr/bin/phpunit on line 38
PHP Stack trace:
PHP 1. {main}() /usr/bin/phpunit:0
root@ubuntu:~# find / -name CodeCov*
root@ubuntu:~#
As you can see there is no such file or folder in my PC. What to do?
如您所见,我的 PC 中没有这样的文件或文件夹。该怎么办?
I tried to reinstall it many times (with apt-get, pear, Synaptic PM...), but always get the same result.
我多次尝试重新安装它(使用 apt-get、pear、Synaptic PM...),但总是得到相同的结果。
采纳答案by Johnny
Problem solved.
问题解决了。
Follow @David Harkness comment I tried to install PHP_CodeCoverage and then I realized that my PEAR Installer is too old. I Upgraded it to 1.9.2 and then reinstalled PHPUnit.
按照@David Harkness 的评论我尝试安装 PHP_CodeCoverage,然后我意识到我的 PEAR 安装程序太旧了。我将其升级到 1.9.2,然后重新安装了 PHPUnit。
$ wget http://pear.php.net/go-pear.phar
$ php go-pear.phar
$ pear install phpunit/PHPUnit
What's quite strange because all software was freshly installed week ago.
很奇怪,因为所有软件都是在一周前全新安装的。
Answer. How I installed PHPUnit finally.
回答。我最终是如何安装 PHPUnit 的。
sudo pear channel-discover pear.phpunit.de
sudo pear channel-discover components.ez.no
sudo pear channel-discover pear.symfony-project.com
sudo pear install phpunit/PHP_CodeCoverage
sudo pear install phpunit/PHPUnit
If You still have problems try to update PEAR:
如果您仍有问题,请尝试更新 PEAR:
sudo wget http://pear.php.net/go-pear.phar
sudo php go-pear.phar
回答by Nithin Chacko Ninan
To get the latest version of pear and phpunit.
获取最新版本的 pear 和 phpunit。
pear upgrade
pear upgrade pear
pear upgrade phpunit/PHPUnit
回答by drewag
The other solutions here did not work for me. I finally found a solution that worked for me here: http://markojakic.net/configure-phpunit-and-pear-in-ubuntu-12-04
这里的其他解决方案对我不起作用。我终于在这里找到了一个对我有用的解决方案:http: //markojakic.net/configure-phpunit-and-pear-in-ubuntu-12-04
Essentially pear by default for me was installing binaries to my home directory. To fix it I ran the following commands
对我来说,默认情况下基本上梨是将二进制文件安装到我的主目录。为了修复它,我运行了以下命令
sudo pear config-set bin_dir /usr/bin
sudo pear config-set doc_dir /usr/share/php/doc
sudo pear config-set php_dir /usr/share/php
sudo pear config-set cfg_dir /usr/share/php/cfg (make (sudo mkdir cfg) directory here)
sudo pear config-set data_dir /usr/share/php/data
sudo pear config-set test_dir /usr/share/php/test
sudo pear uninstall phpunit/PHPUnit
sudo pear install phpunit/PHPUnit
回答by Giovanni Toraldo
PHAR FTW!
法尔FTW!
$ wget http://pear.phpunit.de/get/phpunit.phar
$ chmod +x phpunit.phar
Ref: https://github.com/sebastianbergmann/phpunit/blob/master/README.md
参考:https: //github.com/sebastianbergmann/phpunit/blob/master/README.md
回答by acpmasquerade
configure channel autodiscovery
sudo pear config-set auto_discover 1
simply upgrade / install phpunit with --alldeps flag enabled
sudo pear upgrade --alldeps channel://pear.phpunit.de/PHPUnit
配置通道自动发现
须藤梨配置集 auto_discover 1
只需在启用 --alldeps 标志的情况下升级/安装 phpunit
sudo pear upgrade --alldeps channel://pear.phpunit.de/PHPUnit
and it automatically does the necessary magics. :)
它会自动执行必要的魔法。:)
Update:http://pear.phpunit.de/has gone away (Returns 410)
更新:http: //pear.phpunit.de/已经消失(返回 410)