php 我如何只更新一个 Composer 依赖项?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/19148727/
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 would I only update one composer dependency?
提问by zerkms
I expected that
我期望
composer update videlalvaro/php-amqplib
would only update one dependency, but instead of that it updates all.
只会更新一个依赖项,而不是更新所有依赖项。
What am I missing?
我错过了什么?
PS: this dependency is defined as "videlalvaro/php-amqplib": "2.2.0"
in composer.json
PS:这种依赖性被定义为"videlalvaro/php-amqplib": "2.2.0"
在composer.json
PPS: the composer version used is 3da05c68f9561fa822c522b1815435ff990493ff 2013-10-02 14:25:06
PPS:使用的作曲家版本是 3da05c68f9561fa822c522b1815435ff990493ff 2013-10-02 14:25:06
PPPS: the actual output:
PPPS:实际输出:
$ composer.phar update videlalvaro/php-amqplib --no-dev
Loading composer repositories with package information
Updating dependencies
Your requirements could not be resolved to an installable set of packages.
Problem 1
- symfony/icu v1.2.0 requires lib-icu >=4.4 -> the requested linked library icu has the wrong version installed or is missing from your system, make sure to have the extension providing it.
- symfony/icu v1.2.0 requires lib-icu >=4.4 -> the requested linked library icu has the wrong version installed or is missing from your system, make sure to have the extension providing it.
- Installation request for symfony/icu == 1.2.0.0 -> satisfiable by symfony/icu[v1.2.0].
回答by Danack
The command composer update videlalvaro/php-amqplib
does just update that dependency. However it doesn't disable the other dependency checking that Composer does.
该命令composer update videlalvaro/php-amqplib
只会更新该依赖项。但是,它不会禁用 Composer 所做的其他依赖项检查。
What the error message is complaining about is that the lib-icu is not available on your system. Apparently this would be solved by installing the PHP Intl extension.
错误消息抱怨的是 lib-icu 在您的系统上不可用。显然,这可以通过安装 PHP Intl 扩展来解决。
You would see similar issues if you did a composer update on a project that required PHP 5.5 in one of it's requires, downgraded to PHP 5.4 and then ran composer update on a separate require, that didn't require PHP 5.5. Even though you wouldn't be updating the require that needs PHP 5.5, the requirements for that package would not be resolvable, and so Composer would fail.
如果您对一个需要 PHP 5.5 的项目进行了 Composer 更新,其中一个需要,您会看到类似的问题,降级到 PHP 5.4,然后在不需要 PHP 5.5 的单独要求上运行 Composer 更新。即使您不会更新需要 PHP 5.5 的需求,该包的需求也无法解决,因此 Composer 会失败。
In your case, even though you're just trying to update videlalvaro/php-amqplib
to the latest version, the requirements for symfony/icu
aren't met, and so the composer update fails.
在您的情况下,即使您只是尝试更新videlalvaro/php-amqplib
到最新版本,但symfony/icu
不满足的要求,因此作曲家更新失败。
Edit
编辑
To try to be helpful, I'm guessing you re-installed PHP since you last did an update, and either removed or forgot to install the PHP Intl extension. Composer can't satisfactorily satisfy the requirements your composer.json is setting, and so is defaulting to doing nothing, rather than knowingly doing an update where the requirements aren't met.
为了提供帮助,我猜您自从上次更新后重新安装了 PHP,并且删除或忘记安装 PHP Intl 扩展。Composer 无法令人满意地满足您的 composer.json 设置的要求,因此默认不执行任何操作,而不是在不满足要求的情况下故意进行更新。
So basically, you need to install the PHP extensions that are required for your existing installed software to run, and then Composer will be able to update the single package you want to update, as well as meet the requirements for the other packages.
所以基本上,您需要安装现有已安装软件运行所需的 PHP 扩展,然后 Composer 将能够更新您要更新的单个包,以及满足其他包的要求。
回答by hejdav
tl;dr:
tl;博士:
You can list more than onedependency to update in one command:
您可以在一个命令中列出多个要更新的依赖项:
composer update one/dependency second/dependency other/dependency
Story:
故事:
If you want to update only one dependency (composer update some/dependency
), you may face an issue that request is not satisfiable due to some other dependency is installed in wrong version. And that one does not necessarily must be listed in your composer.json
, it could be just dependency of some other dependency.
如果您只想更新一个依赖项 ( composer update some/dependency
),您可能会面临由于其他依赖项安装在错误版本中而导致请求无法满足的问题。而且那个不一定必须列在您的 中composer.json
,它可能只是某个其他依赖项的依赖项。
E.g. I wanted to update only and only google/apiclient
, but calling composer update google/apiclient
complained, that google/auth
(dependency of apiclient) requires guzzlehttp/psr7
in version 1.2.3
. I had 1.3.0
installed. The guzzlehttp/psr7
was not listed in my composer.json
. What I had to do, was to call:
例如,我只想更新并且只更新google/apiclient
,但调用composer update google/apiclient
抱怨,google/auth
(apiclient 的依赖性)需要guzzlehttp/psr7
version 1.2.3
。我已经1.3.0
安装了。该guzzlehttp/psr7
不是在我列出的composer.json
。我必须做的是打电话:
composer update guzzlehttp/psr7 google/apiclient
and that's it! Just update the package you want, and if composer tells you, that you need to update (or downgrade :-)) some other package, list it in the command.
就是这样!只需更新你想要的包,如果 composer 告诉你,你需要更新(或降级 :-))其他一些包,在命令中列出它。