简体   繁体   English

无法在Ubuntu中升级PHPUnit

[英]Cant able to upgrade PHPUnit in ubuntu

I am trying to upgrade PHPUnit to latest version but I am getting error "install failed". 我正在尝试将PHPUnit升级到最新版本,但出现错误“安装失败”。

I installed PHPUnit with some online tutorial. 我通过一些在线教程安装了PHPUnit。

$ phpunit --version
PHPUnit 5.1.3 by Sebastian Bergmann and contributors.

I believe the current version is 5.5. 我相信当前的版本是5.5。 I am trying the following command. 我正在尝试以下命令。

$ sudo pear install -a -f phpunit/PHPUnit

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

I tried different command from another tutorial: 我尝试了与另一个教程不同的命令:

$ pear config-set auto_discover 1
config-set succeeded
$ pear upgrade
downloading Archive_Tar-1.4.2.tgz ...
Starting to download Archive_Tar-1.4.2.tgz (20,624 bytes)
........done: 20,624 bytes
upgrade ok: channel://pear.php.net/Archive_Tar-1.4.2

$ pear install pear.phpunit.de/PHPUnit

Attempting to discover channel "pear.phpunit.de"...
downloading phpunit.de ...
Starting to download phpunit.de (5,392 bytes)
.....done: 5,392 bytes
unknown channel "pear.phpunit.de" in "pear.phpunit.de/PHPUnit"
invalid package name/package file "pear.phpunit.de/PHPUnit"
install failed

I am new to Ubuntu so kindly help me to solve this issue. 我是Ubuntu的新手,所以请帮助我解决此问题。

sudo pear install -a -f phpunit/PHPUnit 须藤梨安装-a -f phpunit / PHPUnit

PHPUnit discontinued the installation using PEAR in April 2014. The most recent versions that can be installed using PEAR are 3.7.35 and 4.0.17. PHPUnit在2014年4月停止使用PEAR进行安装 。可以使用PEAR安装的最新版本是3.7.35和4.0.17。

Take a look at the PHPUnit documentation and pick one of the methods described there. 查看PHPUnit文档,然后选择其中描述的方法之一。 Make sure your system passes the requirements (PHP version) before starting. 在开始之前,请确保您的系统通过了要求(PHP版本)。

The PHP Archive (PHAR) installation method can be used to install PHPUnit globally or only for one user. PHP Archive(PHAR)安装方法可用于全局安装PHPUnit或仅用于一个用户。 To install it globally, run which phpunit before installation to find out if your current version is installed in /usr/local/bin/phpunit or somewhere else and put the path returned by this command in the mv command. 要全局安装它, which phpunit在安装前运行which phpunit ,以了解当前版本是安装在/usr/local/bin/phpunit还是其他位置,并将此命令返回的路径放在mv命令中。 To install it locally just skip the mv command (but remember where you installed it or put it into the path). 要在本地安装它,只需跳过mv命令(但请记住将其安装在哪里或放在路径中)。

The Composer method is easier and it is the best if your project already uses Composer to manage its dependencies. 如果您的项目已经使用Composer来管理其依赖项,则Composer方法更容易,并且是最好的方法 Its main advantage is that different projects that uses different versions of PHP can use different versions of PHPUnit. 它的主要优点是,使用不同版本的PHP的不同项目可以使用不同版本的PHPUnit。

If your current version of PHPUnit was installed by Ubuntu then the best method to upgrade it is to use the tools provided by Ubuntu. 如果当前版本的PHPUnit是由Ubuntu安装的,则升级它的最佳方法是使用Ubuntu提供的工具。 Run: 跑:

sudo apt-get install phpunit

to upgrade PHPUnit to the most recent version provided by Ubuntu. 将PHPUnit升级到Ubuntu提供的最新版本。 Unfortunately, like all the other distributions, Ubuntu doesn't provide the cutting edge versions of software programs but an older, stable, well-tested version. 不幸的是,与所有其他发行版一样,Ubuntu没有提供软件程序的最新版本,而是提供了较旧的,稳定的,经过测试的版本。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM