Jimmix
Jimmix

Reputation: 6506

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. Example:

{
    "require": {
        "vendor/my-private-repo": "dev-master"
    },
    "repositories": [
        {
            "type": "vcs",
            "url":  "[email protected]: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.

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?

Upvotes: 10

Views: 5441

Answers (2)

Luboš Remplík
Luboš Remplík

Reputation: 636

Use

composer config --global --editor

Then next to config add repositories with yours, e.g.

{
  config: {},
  repositories: [
    {
      type: vcs,
      url: [email protected]:vendor/package.git
    }
  ]
}

Upvotes: 12

7ochem
7ochem

Reputation: 2350

You could set all repositories in you Composer home directory (find where it is with 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).

See the docs on this file: 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. With Satis you can host a single repository that references where all your packages are located (e.g. Bitbucket, GitHub or otherwise).

Upvotes: 4

Related Questions