在 CentOS 上使用 PEAR 安装 PHPUnit

在 CentOS 上使用 PEAR 安装 PHPUnit

我正在尝试在运行 CentOS 5.8 的 Linux 机器上安装 PHPUnit,但遇到了一大堆问题。

我正在运行 PHP 版本 5.4.12(Remi 安装)。

/usr/share/pear首先要注意的奇怪的事情是,我在和 处似乎都有两个梨形装置/usr/share/php

首先我尝试

pear install --alldeps php/PHPUnit

这给了我:

phpunit/PHPUnit requires PEAR Installer (version >= 1.9.4), installed version is 1.4.9
phpunit/File_Iterator requires PEAR Installer (version >= 1.9.2), installed version is 1.4.9
phpunit/Text_Template requires PEAR Installer (version >= 1.9.4), installed version is 1.4.9
phpunit/PHP_CodeCoverage requires PEAR Installer (version >= 1.9.4), installed version is 1.4.9
phpunit/PHP_CodeCoverage requires package "phpunit/File_Iterator" (version >= 1.3.0)
phpunit/PHP_CodeCoverage requires package "phpunit/Text_Template" (version >= 1.1.1)
phpunit/PHP_CodeCoverage can optionally use PHP extension "xdebug" (version >= 2.0.5)
phpunit/PHP_Timer requires PEAR Installer (version >= 1.9.2), installed version is 1.4.9
phpunit/PHPUnit_MockObject requires PEAR Installer (version >= 1.9.4), installed version is 1.4.9
phpunit/PHPUnit_MockObject requires package "phpunit/Text_Template" (version >= 1.1.1)
phpunit/PHPUnit_MockObject can optionally use PHP extension "soap"
phpunit/PHP_Invoker requires PEAR Installer (version >= 1.9.4), installed version is 1.4.9
phpunit/PHP_Invoker requires package "phpunit/PHP_Timer" (version >= 1.0.1)
phpunit/PHP_TokenStream requires PEAR Installer (version >= 1.9.4), installed version is 1.4.9
No valid packages found
install failed

我的下一步行动是升级梨:

Skipping package "pear/PEAR", already installed as version 1.9.4
downloading Structures_Graph-1.0.4.tgz ...
Starting to download Structures_Graph-1.0.4.tgz (30,318 bytes)
.........done: 30,318 bytes

Warning: strtotime(): It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected the timezone 'UTC' for now, but please set date.timezone to select your timezone. in Validate.php on line 486
ERROR: unable to unpack /tmp/tmp4Gb17e/Structures_Graph-1.0.4.tgz

我在这里注意到的是,它说我拥有最新版本(1.9.4)。pear version相反,它告诉我(1.4.9)。我不确定 tar 文件错误是什么问题。

接下来我运行yum remove php-pear以便尝试使用最新版本重新安装:

Running Transaction
  Erasing        : php-pear                                                                                                                                                                                                              1/1

Removed:
  php-pear.noarch 1:1.4.9-8.el5

Complete!

我现在已使用重新安装了 pear sudo yum install php-pear,并按照列出的说明进行操作这里,但现在当我尝试安装 PHPUnit 时,出现了与以前相同的错误(PEAR 版本错误)。为什么当我手动安装 pear 时,它没有提供最新的软件包?

我现在有点迷茫了,似乎有两个 PEAR 安装,我不知道如何清除它们并从头开始。有人知道如何纠正这种情况吗?我是不是应该重新编译 PHP 并重新开始?

谢谢你的帮助。

答案1

好的,最终我通过手动下载并安装 PEAR 实现了这个功能:

wget http://pear.php.net/go-pear.phar # Download the file
php go-pear.phar # Execute the file via PHP

我没有意识到的是,PEAR 可能太过时了,无法自己做到这一点(多亏了这个帖子

然后我就可以安装 PHPUnit 了。

相关内容