通过Composer仅安装单个软件包,而不更新其他软件包 [英] Installing only single package via Composer without updating other packages
问题描述
我需要在项目中安装一个作曲家软件包- maatwebsite / excel〜2.1.0
。每次composer更新时,它都会更新composer.json中的所有软件包。我该如何避免除了excel库之外还更新软件包?
I need to install a single composer package into a project - maatwebsite/excel ~2.1.0
. Each time composer updates, it updates all packages in composer.json. How can I avoid updating packages aside from the excel library?
我尝试了以下命令,但它们似乎不起作用:
I have tried the following commands but they don't seem to be working:
composer require maatwebsite/excel ~2.1.0
composer require vendor/maatwebsite/excel ~2.1.0
composer update maatwebsite/excel ~2.1.0
composer update vendor/maatwebsite/excel ~2.1.0
I' ve也尝试过使用--lock属性,但这也无法正常工作。
I've also tried using the --lock attribute but that's also not working.
有人可以告诉我我在做什么错吗?
Can anybody tell me what I am doing wrong?
推荐答案
要安装具有特定版本的composer程序包,请文档建议使用冒号。
To install a composer package with a specific version the docs suggest the use of a colon.
composer需要maatwebsite / excel:〜2.1.0-无需更新
此外,composer cli工具 composer help需要
帮助如下:
Also, the composer cli tool composer help require
help reads:
必需的软件包名称可选地包括版本约束,例如
foo / bar或foo / bar:1.0.0或foo / bar = 1.0.0或 foo / bar 1.0.0
Required package name optionally including a version constraint, e.g. foo/bar or foo/bar:1.0.0 or foo/bar=1.0.0 or "foo/bar 1.0.0"
因此,要使用空格分隔的版本号,您需要在软件包/版本组合周围加上引号。即:
So to use a space separated version number, you needed the quotation marks surrounding the package/version combination. That is:
composer需要 maatwebsite / excel〜2.1.0 --no-update
也应该为您工作。
这篇关于通过Composer仅安装单个软件包,而不更新其他软件包的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!