安装 pear.phpunit.de/PHPUnit 时出现问题

Issues while installing pear.phpunit.de/PHPUnit

我试图告诉 pear 使用此命令可以在何处找到 PHPUnit:

sudo pear channel-discover pear.phpunit.de

输出为:

Discovering channel pear.phpunit.de over http:// failed with message: channel-add: Cannot open "http://pear.phpunit.de/channel.xml" (File http://pear.phpunit.de:80/channel.xml not valid (received: HTTP/1.1 410 Gone
))
Trying to discover channel pear.phpunit.de over https:// instead
Discovery of channel "pear.phpunit.de" failed (channel-add: Cannot open "https://pear.phpunit.de/channel.xml" (File https://pear.phpunit.de:443/channel.xml not valid (received: HTTP/1.1 410 Gone
)))

我尝试了以下命令:

sudo pear channel-update pear.php.net
sudo pear upgrade-all

然后我再次运行channel-discover命令。我得到了如上所示的相同错误。
我什至尝试了这些命令:

sudo pear config-set auto_discover 1

输出:

config-set succeeded

然后我尝试了这个命令:

sudo pear install pear.phpunit.de/PHPUnit

输出:

Attempting to discover channel "pear.phpunit.de"...
Attempting fallback to https instead of http on channel "pear.phpunit.de"...
unknown channel "pear.phpunit.de" in "pear.phpunit.de/PHPUnit"
invalid package name/package file "pear.phpunit.de/PHPUnit"
install failed  

所以我访问了这个 link: https://pear.phpunit.de/channel.xml 并且它显示 410 gone 错误。还有其他替代方法吗?

您不能再使用 pear 安装 phpunit: https://github.com/sebastianbergmann/phpunit/wiki/End-of-Life-for-PEAR-Installation-Method

但您仍然可以使用 phar 文件安装它: https://phpunit.de/getting-started.html

或使用作曲家: https://phpunit.de/manual/current/en/installation.html#installation.composer

现在大多数人只是作曲家。但是因为你似乎在 Ubuntu 你总是可以做:

sudo apt-get install phpunit

下载适用于我的 phar 存档:

https://github.com/Mayflower/PHP_CodeBrowser

wget https://github.com/mayflower/PHP_CodeBrowser/releases/download/1.1.1/phpcb-1.1.1.phar
mv phpcb-1.1.1.phar /usr/local/bin/phpcb
chmod a+x /usr/local/bin/phpcb

phpcb --version
PHP_CodeBrowser version 1.1.1

对于那些使用 RHEL 发行版(CentOS/Fedora/ 等)但尚未使用 composer 的用户,您可以使用 YUM 安装 phpunit:

yum install phpunit