php - 通过 Composer 只安装单个包而不更新其他包

我需要在一个项目中安装一个 composer 包 - maatwebsite/excel ~2.1.0 .每次 composer 更新时,它都会更新 composer.json 中的所有包。除了 excel 库之外,如何避免更新包?

我尝试了以下命令,但它们似乎不起作用:

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

我也试过使用 --lock 属性,但这也不起作用。

谁能告诉我我做错了什么?

最佳答案

要安装具有特定版本的 Composer 包 docs建议使用冒号。
composer require maatwebsite/excel:~2.1.0 --no-update
此外,composer cli 工具 composer help require帮助内容如下:

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"



因此,要使用空格分隔的版本号,您需要在包/版本组合周围加上引号。那是:
composer require "maatwebsite/excel ~2.1.0" --no-update
也应该为你工作。

https://stackoverflow.com/questions/41316792/

相关文章:

python - 在 Tkinter 中创建向导

angularjs - 在带有过滤的ng-repeat中反向计数

security - Webpack 样式加载器 appendChild 对 CSP 不友好

apache-spark - Spark 溢出独立于分配的执行程序内存

.net - Android Xamarin - 带有 ObservableCollection 的

elixir - 编译 riak_core 项目时,Mix 在 deps.compile 上挂起

r - 如何在 R 中获取面板数据固定效应回归的 corr(u_i, Xb)

android - 安装失败 INSTALL_PARSE_FAILED_MANIFEST_MALFO

wpf - 在其 winforms 父级中拖动托管 WPF 控件吞噬的事件

angularjs - 在 Controller 函数之外的脚本中读取 AngularJS 表达式