简体   繁体   English

PHP Composer 全局配置私有仓库 URL 列表

[英]PHP Composer Global Configuration Private Repositories URL List

PHP Composer allows you to define it project's composer.json list of urls pointing to private repositories. PHP Composer 允许您定义项目的composer.json指向私有存储库的 URL 列表。 Example:例子:

{
    "require": {
        "vendor/my-private-repo": "dev-master"
    },
    "repositories": [
        {
            "type": "vcs",
            "url":  "git@bitbucket.org:vendor/my-private-repo.git"
        }
    ]
}

But whenever I create a new private repo I need to edit all my projects and add that new repo URL to their composer.json before I am able to request that new package.但是每当我创建一个新的私有存储库时,我都需要编辑我的所有项目并将该新存储库 URL 添加到他们的composer.json 中,然后才能请求该新包。

Is there any global composer configuration where I could store URLs to all of my private repos or even better where I can globally set an URL pointing to a resource that will have a list of all my private repos and their URLs up to date?是否有任何全局作曲家配置,我可以将 URL 存储到我的所有私有存储库,或者甚至更好,我可以全局设置一个指向资源的 URL,该资源将包含我的所有私有存储库及其最新 URL 的列表?

You could set all repositories in you Composer home directory (find where it is with composer config --global home ). 您可以在Composer主目录中设置所有存储库(使用composer config --global home查找位置)。 There is a config.json file in which you can add all the global repositories (global on that machine for all your projects). 有一个config.json文件,您可以在其中添加所有全局存储库(该计算机上所有项目的全局存储库)。

See the docs on this file: https://getcomposer.org/doc/03-cli.md#composer-home-config-json 请参阅此文件上的文档: https : //getcomposer.org/doc/03-cli.md#composer-home-config-json

Unfortunately, you cannot have a central managed way for this out of the box. 不幸的是,开箱即用,您无法采用集中管理的方式。 You could look into Composer Satis for this. 您可以为此寻找Composer Satis With Satis you can host a single repository that references where all your packages are located (eg Bitbucket, GitHub or otherwise). 使用Satis,您可以托管一个引用所有包所在位置的存储库(例如Bitbucket,GitHub或其他)。

Use

composer config --global --editor

Then next to config add repositories with yours, eg然后在config旁边添加您的repositories ,例如

{
  config: {},
  repositories: [
    {
      type: vcs,
      url: git@github.com:vendor/package.git
    }
  ]
}

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

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