简体   繁体   English

将其他存储库用于Composer软件包

[英]Use another repository for Composer package

I want to require a package ( avanzu/admin-theme-bundle ) but I want to, instead of downloading it from the main Github repository, download it from another fork ( jibundeyare/admin-theme-bundle , for a bugfix). 我想要一个软件包( avanzu/admin-theme-bundle ),但我不想从主Github存储库下载它,而是从另一个fork( jibundeyare/admin-theme-bundle ,获取错误修复)下载了该jibundeyare/admin-theme-bundle How am I supposed to edit my composer.json in order to do this ? 我应该如何编辑composer.json来做到这一点?

You can add a custom source location as shown on the repositories help page . 您可以添加自定义源位置, 如存储库帮助页面上所示

There are a few use cases for this. 有一些用例。 The most common one is maintaining your own fork of a third party library. 最常见的一种方法是维护自己的第三方库库。 If you are using a certain library for your project and you decide to change something in the library, you will want your project to use the patched version. 如果您为项目使用某个库,并且决定更改该库中的某些内容,则将希望您的项目使用已修补的版本。 If the library is on GitHub (this is the case most of the time), you can simply fork it there and push your changes to your fork. 如果该库位于GitHub上(大多数情况下是这种情况),则可以将其存储在该库中,然后将所做的更改推送到该存储库中。 After that you update the project's composer.json . 之后,您将更新项目的composer.json All you have to do is add your fork as a repository and update the version constraint to point to your custom branch. 您所要做的就是将fork添加为存储库,并更新版本约束以指向您的自定义分支。 Your custom branch name must be prefixed with "dev-" . 您的自定义分支名称必须以"dev-"为前缀。 For version constraint naming conventions see Libraries for more information. 有关版本约束的命名约定,请参见库以获取更多信息。

Example assuming you patched monolog to fix a bug in the bugfix branch: 假设您修补了独白以修复bugfix分支中的错误的示例:

 { "repositories": [ { "type": "vcs", "url": "https://github.com/igorw/monolog" } ], "require": { "monolog/monolog": "dev-bugfix" } } 

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

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