How to correctly require a specific commit in Composer so that it would be available for dependent packages?(如何正确要求 Composer 中的特定提交,以便它可用于依赖包?)
问题描述
我有一个库 foo/foo-lib
,它 需要
来自 GitHub 的特定提交:
I have a library foo/foo-lib
which requires
a specific commit from GitHub:
{
"name": "foo/foo-lib",
"repositories": [
{
"type": "vcs",
"url": "https://github.com/KnpLabs/Gaufrette.git"
}
],
"require": {
"knplabs/gaufrette": "dev-master#2633721877cae79ad461f3ca06f3f77fb4fce02e"
}
}
而且效果很好:
$ composer update
Loading composer repositories with package information
Updating dependencies (including require-dev)
- Updating knplabs/gaufrette dev-master (2633721 => 2633721)
Checking out 2633721877cae79ad461f3ca06f3f77fb4fce02e
Generating autoload files
但是当我在其他项目中需要该库时:
but when I require that library in other project:
{
"name": "bar/bar-app",
"repositories": [
{
"type": "vcs",
"url": "ssh://git.example.com/foo-lib"
}
],
"require-dev": {
"foo/foo-lib": "dev-master"
}
}
它产生依赖错误:
Your requirements could not be resolved to an installable set of packages.
Problem 1
- Installation request for foo/foo-lib dev-master -> satisfiable by foo/foo-lib[dev-master].
- foo/foo-lib dev-master requires knplabs/gaufrette dev-master#2633721877cae79ad461f3ca06f3f77fb4fce02e -> no matching package found.
所以我的问题是:如何正确 require
我的库中来自 GitHub 的特定提交,以便它可以在依赖包中使用?
So my question is: how to correctly require
the specific commit from GitHub in my library, so that it would be available in dependent packages?
推荐答案
你必须在你的库和应用程序中显式地在该哈希处需要 Gaufrette 库,并带有 dev
标志.像这样的东西应该在应用程序 composer.json
中工作:
You'll have to explicitly require the Gaufrette library at that hash, with a dev
flag, in both your library and your application. Something like this should work in the application composer.json
:
{
"name": "bar/bar-app",
"repositories": [
{
"type": "vcs",
"url": "ssh://git.example.com/foo-lib"
}
],
"require-dev": {
"foo/foo-lib": "dev-master",
"knplabs/gaufrette": "dev-master#2633721877cae79ad461f3ca06f3f77fb4fce02e"
}
}
来自文档:
如果您的依赖项之一依赖于不稳定的包您还需要明确要求它,以及它足够的稳定标志.
If one of your dependencies has a dependency on an unstable package you need to explicitly require it as well, along with its sufficient stability flag.
文档还建议您需要在 bar/bar-app
Composer 文件中包含 Gaufrette 的存储库,尽管在这种情况下这听起来没有必要.我不知道为什么.
The documentation also suggests that you'll need to include the repository for Gaufrette in your bar/bar-app
Composer file, though it sounds like this wasn't necessary in this case. I'm not sure why.
这篇关于如何正确要求 Composer 中的特定提交,以便它可用于依赖包?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:如何正确要求 Composer 中的特定提交,以便它可用于依赖包?
基础教程推荐
- mysqli_insert_id 是否有可能在高流量应用程序中返回 2021-01-01
- 通过 PHP SoapClient 请求发送原始 XML 2021-01-01
- 如何在 PHP 中的请求之间持久化对象 2022-01-01
- Libpuzzle 索引数百万张图片? 2022-01-01
- WooCommerce 中选定产品类别的自定义产品价格后缀 2021-01-01
- 在多维数组中查找最大值 2021-01-01
- 在 PHP 中强制下载文件 - 在 Joomla 框架内 2022-01-01
- 在 Woocommerce 中根据运输方式和付款方式添加费用 2021-01-01
- 超薄框架REST服务两次获得输出 2022-01-01
- XAMPP 服务器不加载 CSS 文件 2022-01-01