Centos

在 CentOS 上使用 PEAR 安裝 PHPUnit

  • April 4, 2018

我正在嘗試在執行 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 並重新開始嗎?

謝謝你的幫助。

好的,所以我最終通過手動下載和安裝 PEAR 來完成這項工作:

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

我沒有意識到 PEAR 可能已經過時而無法為自己做這件事(感謝這篇文章

這讓我可以安裝 PHPUnit。

引用自:https://serverfault.com/questions/486224