PHPUnit、PEAR 升级错误

发布于 2024-12-28 07:34:31 字数 1766 浏览 0 评论 0原文

注意:我已阅读有关此问题的所有问题

PEAR 已在我的系统(Ubuntu 11.10 + Apache/2.2.20)上安装和配置。因为

<?php
require_once 'System.php';
var_dump(class_exists('System', false));
?> 

返回此:(

bool(true)

PEAR 手册:检查 PEAR 是否工作第 4 步

当我尝试使用 phpunit 时,出现此错误。

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 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

出现此错误后,我决定安装它,

sudo /usr/bin/pear install phpunit/PHP_CodeCoverage

但我

phpunit/PHP_CodeCoverage requires PEAR Installer (version >= 1.9.4), installed version is 1.9.2

在使用 sudo pear Upgrade 升级 PEAR 时遇到此错误,

PHP Fatal error:  Call to undefined method PEAR_Registry::packageinfo() in /usr/share/php/PEAR/Dependency2.php on line 687

我不确定问题是什么?

附加

(命令 : 结果)

/usr/bin/pear config-get php_dir : /usr /share/php

配置文件(php.ini)路径(在 phpinfo();) : /etc/php5/apache2

php -c /etc/php5/apache2/php.ini -r 'echo get_include_path()."\n";' : .:/usr/share/php

pear 升级 pear : PHP 致命错误:在 /usr/share/php/PEAR/Dependency2.php 第 687 行调用未定义的方法 PEAR_Registry::packageinfo()

PEAR 版本:已安装 1.9.2 和 php-pear 软件包。

Note : I've read all questions about this problem

PEAR is installed and configured on my system (Ubuntu 11.10 + Apache/2.2.20). Because

<?php
require_once 'System.php';
var_dump(class_exists('System', false));
?> 

Returning this :

bool(true)

(PEAR Manual : Checking if PEAR works Step 4)

When i tried to use phpunit i'm getting this error.

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 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

After this error i've decided to install it

sudo /usr/bin/pear install phpunit/PHP_CodeCoverage

But i'm getting

phpunit/PHP_CodeCoverage requires PEAR Installer (version >= 1.9.4), installed version is 1.9.2

I'm getting this error when upgrading PEAR with sudo pear upgrade

PHP Fatal error:  Call to undefined method PEAR_Registry::packageinfo() in /usr/share/php/PEAR/Dependency2.php on line 687

I'm not sure what is the problem ?

ADDITIONAL

(command : result)

/usr/bin/pear config-get php_dir : /usr/share/php

Configuration File (php.ini) Path (on phpinfo();) : /etc/php5/apache2

php -c /etc/php5/apache2/php.ini -r 'echo get_include_path()."\n";' : .:/usr/share/php

pear upgrade pear : PHP Fatal error: Call to undefined method PEAR_Registry::packageinfo() in /usr/share/php/PEAR/Dependency2.php on line 687

PEAR Version : 1.9.2 and php-pear package installed.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

有木有妳兜一样 2025-01-04 07:34:31

PEAR 1.9.2 已经过时并且损坏,无法用较新的 Pear 服务器基础设施进行修复。

我不知道为什么发行版仍然坚持使用刚刚损坏的东西:)

通过 go-pear.phar 安装新的 pear 并确保您拥有 pear 版本 1.9.4,然后强制 pear 忽略它的旧版本 缓存文件

sudo pear install --force --alldeps phpunit/phpunit

使用“摆脱” 老梨:

sudo apt-get purge php5-pear

现在

which pear

应该会导致找不到命令。如果它仍然存在,请删除 /usr/share/php 中的二进制文件和关联的 php 类。

从您的控制台历史记录来看,我想说您没有使用 sudo 权限安装新的 pear,因此它落在 /home/ 或 /usr/local/ 中,而不是在默认系统位置。

就没关系,

  • 只要你摆脱旧的 pear
  • 将 php.ini include_path 更改为新的 pear 安装位置

PEAR 1.9.2 is outdated and broken beyond any hope of repair with newer pear server infrastructure.

I have no clue why distributions still insist on something that is just broken :)

Install a new pear via go-pear.phar and make sure you have pear version 1.9.4 and then force pear to ignore it's old cache files using

sudo pear install --force --alldeps phpunit/phpunit

Getting rid of the old pear:

sudo apt-get purge php5-pear

Now

which pear

should result in the command not being found. If it is still there delete the binary and the associated php classes in /usr/share/php.

From your console history I'd say you didn't install the new pear with sudo rights so it landed in /home/ or in /usr/local/ instead of in the default system location.

It shouldn't matter as long as you

  • Get rid of the old pear
  • Change your php.ini include_path to the new pear install location
热血少△年 2025-01-04 07:34:31

针对特定环境进行故障排除可能很困难...但是,这里...

在不使用实际的 pear.phpunit.de 通道安装 PHPUnit 时遇到了问题,尤其是在尝试使用 apt-get 或 yum 等包管理器时。首先,您需要确保您的 pear 安装是最新的。从包管理器中终止现有安装:

  • sudo apt-get purge php5-pear

然后确保删除可执行二进制文件(如果它仍然存在)。这可能是 /usr/bin/pear,但您可能需要根据您的环境修改路径:

  • rm /usr/bin/pear

接下来通过下载 go-pear.phar 和安装新的 pear执行它。 确保使用 sudo 权限(或以 root 身份)安装它,以便将其安装在正确的位置

然后,您可以通过执行下一个命令来验证 pear 是否正常工作。如果是这样,您将获得命令列表:

  • pear help

最后,升级 pear (以防万一 - 毕竟您刚刚使用 go-pear.phar 获得了最新版本)。此后,确保您使用实际的 pear.phpunit.de 通道来安装 PHPUnit:

  • sudo pear Upgrade PEAR
  • sudo pear config-set auto_discover 1
  • sudo pear install --alldeps pear.phpunit.de/PHPUnit

这对我来说效果很好...希望有帮助。

更新

要使 PHPUnit 的所有功能正常工作,您可能还需要执行以下操作:

  • sudo pear install pear.phpunit.de/PHPUnit_MockObject

您会认为 --alldeps 将涵盖这一点,但是...

更新 2

此方法不适用于当前的 Ubuntu 11.10,因为它
安装破碎的梨安装程序 1.9.2 ...

鉴于使用 go-pear.phar 安装方法持续出现问题,这是另一种方法 ...

  • sudo apt-get install php-pear

接下来,告诉 PEAR 更新自己的频道。

  • sudo pear channel-update pear.php.net

然后,告诉 PEAR 将自身升级到最新版本。

  • sudo pear Upgrade-all

最后,按照上面的规定安装 PHPUnit ...

  • sudo pear config-set auto_discover 1
  • sudo pear install --alldeps pear.phpunit.de/PHPUnit

It can be difficult to troubleshoot for a specific environment ... but, here goes ...

I've had issues when not using the actual pear.phpunit.de channel to install PHPUnit, especially when trying to use a package manager like apt-get or yum. First, you need to be sure your pear installation is up to date. Kill the existing install from your package manager:

  • sudo apt-get purge php5-pear

Then make sure you delete the executable binary file if it still exists. This is probably /usr/bin/pear, but you may need to modify the path based on your environment:

  • rm /usr/bin/pear

Next install the new pear by downloading go-pear.phar and executing it. Make sure you install it with sudo rights (or as root) so that it is installed in the correct location:

You can then verify that pear works by executing the next command. If so, you'll get a list of commands:

  • pear help

Finally, upgrade pear (just in case -- you did just get the latest version using go-pear.phar, after all). After this, make sure you use the actual pear.phpunit.de channel to install PHPUnit:

  • sudo pear upgrade PEAR
  • sudo pear config-set auto_discover 1
  • sudo pear install --alldeps pear.phpunit.de/PHPUnit

This has worked well for me ... hope it helps.

UPDATE

To get all the features of PHPUnit working you'll likely need to also do the following:

  • sudo pear install pear.phpunit.de/PHPUnit_MockObject

You'd think --alldeps would cover this but ...

UPDATE 2

This method won't work with the current Ubuntu 11.10 because it
installs the broken pear installer 1.9.2 ...

Here's an alternative method given your continued issues using the go-pear.phar install method ...

  • sudo apt-get install php-pear

Next, tell PEAR to update its own channel.

  • sudo pear channel-update pear.php.net

Then, tell PEAR to upgrade itself to the newest version.

  • sudo pear upgrade-all

Finally, install PHPUnit as proscribed above ...

  • sudo pear config-set auto_discover 1
  • sudo pear install --alldeps pear.phpunit.de/PHPUnit
您的好友蓝忘机已上羡 2025-01-04 07:34:31

我通过手动安装让我的工作正常运行。

I got mine working by doing a manual installation.

零崎曲识 2025-01-04 07:34:31

我刚刚升级了我的 Ubuntu 系统,并且 PEAR 1.9.4 稳定了。运行

sudo apt-get update
sudo apt-get upgrade

以使您的 Ubuntu 同步并更新到最新状态。

如果您仍然对上述版本感到困扰,我的建议是安装与您的 phpunit 兼容的旧版本 PHP_CodeCoverage。在升级系统之前,我安装了 phpunit-3.5.15(稳定)、PHP_CodeCoverage 1.0.5(稳定)和 PEAR 1.9.2。如果这是您的 phpunit 版本,

sudo pear install PHP_CodeCoverage-1.0.5

则应使用 PEAR 1.9.2 安装 PHP_CodeCoverage。

我希望这对您有所帮助,并且您可以运行单元测试。

I've just upgraded my Ubuntu system and I've got PEAR 1.9.4 stable. Run

sudo apt-get update
sudo apt-get upgrade

to get your Ubuntu synchronised and up to date.

If you were still struggling with the versions as above my suggestion is to install a previous version of PHP_CodeCoverage that is compatible with your phpunit. Before I upgraded my system, I had phpunit-3.5.15 (stable), PHP_CodeCoverage 1.0.5 (stable) installed with PEAR 1.9.2. If this is your phpunit version

sudo pear install PHP_CodeCoverage-1.0.5

should install PHP_CodeCoverage with PEAR 1.9.2.

I hope this helps and you get your unit tests running.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文