Skip to content

Instantly share code, notes, and snippets.

@ulrikkold
Created September 25, 2014 19:12
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save ulrikkold/6893632472eb07a8b15b to your computer and use it in GitHub Desktop.
Save ulrikkold/6893632472eb07a8b15b to your computer and use it in GitHub Desktop.
Using composer.json with private repositories (without using Packagist)
This is mostly a note to my own bad memory. I hope somebody else can use it, too.
When using composer to manage packages, and one or more of these packages (including the root project itself) is not registered on Packagist, then you must include an entry in the "repositories" array in your composer.json.
I am pretty sure this must be noted somewhere in the documentation, but I was not able to find it.
Example:
{
"name": "vendor/PackageA",
"require": "vendor/PackageB",
"repositories": [
{
"type": "vcs",
"url": "git@github.com:vendor/PackageA.git"
},
{
"type": "vcs",
"url": "git@github.com:vendor/PackageB.git"
}
]
}
I was hinted in this direction by this SO question: https://stackoverflow.com/questions/22536978/how-to-solve-the-package-not-available-in-stable-enough-version-error-of-compo
@robertnicjoo
Copy link

robertnicjoo commented Aug 5, 2022

Clean up:

{
  "name":  "vendor/PackageA",
  "require": "vendor/PackageB",
  "repositories": [
    {
      "type": "vcs",
      "url": "git@github.com:vendor/PackageA.git"
    },
    {
      "type": "vcs",
      "url": "git@github.com:vendor/PackageB.git"
    }
  ]
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment