如何修复安装pear时的错误以便安装phpunit


How to fix error when installing pear in order to install phpunit?

我不太确定这个问题是否属于这个论坛,所以如果不是,你即将关闭这个问题,请建议在其他地方问这个问题。

基本上,我需要在Ubuntu 12.04上安装phpunit。通过使用包管理器这样做,我在运行phpunit时得到一个错误:
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

存在解决方案,即将phpunitpear一起安装。

按照pear安装说明,我下载并运行go-pear.phar,它本身产生一个错误

PHP Notice:  Uninitialized string offset: 0 in phar:///home/alexander/opt/src/go-pear.phar/Console/Getopt.php on line 145

有什么建议吗?我也只需要phpunit,所以pear将只用于这种情况一次。

phpunit的安装似乎非常复杂,但这里是解决方案:

    对于Ubuntu 12.04 pear应该已经安装了但是,应该使用最新版本的pear
  • phpunit需要在重新安装前移除

整个过程和每个步骤都在symsymy -world上描述,您可能需要在给定注释中显示的附加步骤。下面是Ubuntu 12.04的完整过程的复制和粘贴:

sudo apt-get remove phpunit
sudo apt-get upgrade pear
sudo pear channel-discover pear.phpunit.de
sudo pear channel-discover pear.symfony-project.com
sudo pear channel-discover components.ez.no
sudo pear channel-discover pear.symfony.com
sudo pear update-channels
sudo pear upgrade-all
sudo pear install --alldeps phpunit/PHPUnit

如果您只需要phpunit,请使用composer..比如作曲家。Json可能看起来像:

{
    "require-dev": {
        "phpunit/phpunit": "3.7.*"
    }
}