This composer plugin adds github and bitbucket protocols support to Composer in order to simplify private repositories handling.
Private Composer uses GitHub and BitBucket APIs to build packages.json virtual file on the fly, with all packages from owner's repositories, which can be used in repository type composer in composer.json file.
Instead of manually adding each one repository separately to composer.json file, e.g.:
{
"repositories": [
{
"type": "vcs",
"url": "https://github.com/PiotrPress/private-repo-1.git"
},
{
"type": "vcs",
"url": "https://github.com/PiotrPress/private-repo-2.git"
}
],
"require": {
"piotrpress/private-repo-1": "dev-master",
"piotrpress/private-repo-2": "*"
}
}use (in this example) github protocol:
{
"repositories": [
{
"type": "composer",
"url": "github://PiotrPress"
}
],
"require": {
"piotrpress/private-repo-1": "dev-master",
"piotrpress/private-repo-2": "*"
}
}- Add the plugin as a global composer requirement:
$ composer global require piotrpress/private-composer- Allow the plugin execution:
$ composer config -g allow-plugins.piotrpress/private-composer trueAdd GitHub/BitBucket API authentication credentials:
$ composer config [--global] http-basic.<host> <username> <password>NOTE: using --global option is recommended to keep credentials outside of project's files.
github.comexample:
$ composer config --global http-basic.github.com x-oauth-basic token- Custom domain example:
$ composer config --global http-basic.example.com x-oauth-basic tokenhost- GitHub's domain, if empty it's equivalent:github.comusername- alwaysx-oauth-basicpassword- GitHub'stoken(generate new one using this link)
bitbucket.orgexample:
$ composer config --global http-basic.bitbucket.org username app_password- Custom domain example:
$ composer config --global http-basic.example.com username app_passwordhost- BitBucket's domain, if empty it's equivalent:bitbucket.orgusername- BitBucket'susernamepassword- BitBucket'sapp_password(generate new one using this link)
{
"repositories": [
{
"type": "composer",
"url": "<github|bitbucket>://<owner>[@<host>]"
}
]
}github.comexample:
{
"repositories": [
{
"type": "composer",
"url": "github://PiotrPress"
}
]
}- Custom domain example:
{
"repositories": [
{
"type": "composer",
"url": "github://PiotrPress@example.com"
}
]
}owner- GitHub's repositoryownerhost- API endpoint domain, if empty it's equivalent:github.com
bitbucket.orgexample:
{
"repositories": [
{
"type": "composer",
"url": "bitbucket://PiotrPress"
}
]
}- Custom domain example:
{
"repositories": [
{
"type": "composer",
"url": "bitbucket://PiotrPress@example.com"
}
]
}owner- BitBucket'sworkspacehost- API endpoint domain, if empty it's equivalent:bitbucket.org
$ composer packages <github|bitbucket>://<owner>[@<host>]Command's output is a valid packages.json file content.
$ composer packages github://PiotrPress > packages.jsonIf there are many repositories to scan, it may be necessary to increase the process timeout.
- PHP >=
7.4version. - Composer ^
2.0version.