php 如何使用 PEAR 正确安装 PHPUnit?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/12536668/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How do I correctly install PHPUnit with PEAR?
提问by twigmac
I have had to de- and reinstall a newer version of PHPUnit following these directions. Now when I'm launching this line
我不得不按照这些说明卸载并重新安装较新版本的 PHPUnit 。现在当我启动这条线时
sudo pear install --alldeps phpunit/PHPUnit
I see an error message, that looks like this.
我看到一条错误消息,看起来像这样。
Unknown remote channel: pear.symfony.com
phpunit/PHPUnit requires package "channel://pear.symfony.com/Yaml" (version >= 2.1.0)
No valid packages found
If I install just Yaml by launching
如果我通过启动只安装 Yaml
sudo pear install symfony/YAML
an older version (1.0.6) will be installed that doesn't meet the dependency of PHPUnit. How can I possibly solve this?
将安装不符合 PHPUnit 依赖性的旧版本 (1.0.6)。我怎么可能解决这个问题?
回答by PutzKipa
I had the same problem while upgrading my phpunit.
我在升级我的 phpunit 时遇到了同样的问题。
This solved the problem:
这解决了这个问题:
pear channel-discover pear.symfony.com
pear install pear.symfony.com/Yaml
Then run:
然后运行:
pear install --alldeps pear.phpunit.de/PHPUnit
OBS: I think the pear install pear.symfony.com/Yamlis not necessary. I'm just posting it because it is exactly the way I solved my problem.
OBS:我认为pear install pear.symfony.com/Yaml没有必要。我只是发布它,因为这正是我解决问题的方式。
回答by Wouter J
Use this, as described in the PHPUnit docs: (i don't what sudo means, this is how I do it on a windows PC):
使用它,如PHPUnit 文档中所述:(我不知道 sudo 是什么意思,这就是我在 Windows PC 上的做法):
pear config-set auto_discover 1
pear install pear.phpunit.de/PHPUnit
回答by Paulo
I also had this error message:
我也有这个错误信息:
Unknown remote channel: pear.symfony.com
未知远程频道:pear.symfony.com
Solved creating an alias:
解决了创建别名的问题:
pear channel-alias pear.symfony-project.com pear.symfony.com
and then
进而
channel-discover pear.symfony-project.com
sudo pear channel-discover components.ez.no
sudo pear update-channels
sudo pear upgrade-all
sudo pear install --force --alldeps phpunit/PHPUnit
回答by Parris
First: locate pearyou may have multiple versions installed and this could be a pain.
首先:locate pear您可能安装了多个版本,这可能会很痛苦。
At work we have something like this in our intranet:
在工作中,我们的内部网中有这样的东西:
sudo [your pear install] channel-update pear.php.net
sudo [your pear install] upgrade pear
sudo [your pear install] channel-discover pear.phpunit.de
sudo [your pear install] install --alldeps phpunit/PHPUnit
I know theres a more automated way to install it using: go-pear ( http://pear.php.net/manual/en/installation.getting.php)
我知道有一种更自动化的安装方式: go-pear ( http://pear.php.net/manual/en/installation.getting.php)
However, if you already have some other install of pear it will totally wreck everything and you'll spend quite some time trying to fix it. I think the biggest hurdle is being able to tell all the libraries where each other is.
但是,如果您已经安装了一些其他的 pear,它将完全破坏一切,并且您将花费相当多的时间来尝试修复它。我认为最大的障碍是能够告诉所有图书馆彼此的位置。
回答by Jie Qin
sudo pear install -a phpunit
sudo pear channel-discover pear.phpunit.de
I had similar problem complaining about "Unknown remote channel: pear.symfony.com". had to do (without sudo, I got weird error about cannot open some file)
我有类似的问题抱怨“未知的远程频道:pear.symfony.com”。必须做(没有 sudo,我收到了关于无法打开某些文件的奇怪错误)
sudo pear channel-discover pear.symfony.com
then
然后
sudo pear install phpunit/PHPUnit
Now I can see phpunit in my /usr/bin
现在我可以在我的 /usr/bin 中看到 phpunit
回答by Bimal
Process mentioned by PutzKipa works however you might need super user privileges. For ubuntu add sudo before each command.
PutzKipa 提到的过程可以工作,但是您可能需要超级用户权限。对于 ubuntu,在每个命令之前添加 sudo。
回答by Peter Teoh
Following Plínio César, I solved it finally, but with slight variation:
在 Plínio César 之后,我终于解决了它,但略有不同:
First I did a "sudo apt-get remove phpunit" to remove the faulty installation. Then using pear to do the phpunit installation:
首先我做了一个“sudo apt-get remove phpunit”来删除错误的安装。然后使用pear进行phpunit安装:
sudo pear install pear.symfony.com/Yaml
须藤梨安装 pear.symfony.com/Yaml
sudo pear channel-discover pear.phpunit.de
sudo pear channel-discover pear.phpunit.de
sudo pear config-set auto_discover 1
须藤梨配置集 auto_discover 1
sudo pear install --alldeps pear.phpunit.de/PHPUnit
须藤梨安装 --alldeps pear.phpunit.de/PHPUnit
Thanks Plinio Cesar!!!
感谢普利尼奥·塞萨尔!!!
回答by karel
The easiest way to obtain PHPUnit in Ubuntu, Debian, Fedora or OpenSUSE is to download a PHP Archive (PHAR) that has all required (as well as some optional) dependencies of PHPUnit bundled in a single file.
在 Ubuntu、Debian、Fedora 或 OpenSUSE 中获取 PHPUnit 的最简单方法是下载 PHP 存档 (PHAR),该存档将 PHPUnit 的所有必需(以及一些可选)依赖项捆绑在一个文件中。
Open the terminal and type:
打开终端并输入:
wget https://phar.phpunit.de/phpunit.phar # download the PHP Archive (PHAR) file
chmod +x phpunit.phar
sudo mv phpunit.phar /usr/local/bin/phpunit
There are many different versions of phpunit.phar at https://phar.phpunit.de/. If you use the first command, it will select and download the latest version.
https://phar.phpunit.de/ 上有许多不同版本的 phpunit.phar 。如果您使用第一个命令,它将选择并下载最新版本。
Note: The /usr/local/bin/path in the last command is correct for Ubuntu, Debian, Fedora and OpenSUSE distributions and also for other Linux distributions that have a /usr/local/bin/directory.
注意:/usr/local/bin/最后一条命令中的路径对于 Ubuntu、Debian、Fedora 和 OpenSUSE 发行版以及其他具有/usr/local/bin/目录的Linux 发行版都是正确的。

