PHPUnit , PEAR upgrading Errors

时光总嘲笑我的痴心妄想 提交于 2019-12-19 05:43:13

问题


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.


回答1:


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



回答2:


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:

  • wget http://pear.php.net/go-pear.phar
  • sudo php go-pear.phar

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



回答3:


I got mine working by doing a manual installation.




回答4:


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.



来源:https://stackoverflow.com/questions/8949963/phpunit-pear-upgrading-errors

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!