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 true
Add 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.com
example:
$ composer config --global http-basic.github.com x-oauth-basic token
- Custom domain example:
$ composer config --global http-basic.example.com x-oauth-basic token
host
- GitHub's domain, if empty it's equivalent:github.com
username
- alwaysx-oauth-basic
password
- GitHub'stoken
(generate new one using this link)
bitbucket.org
example:
$ composer config --global http-basic.bitbucket.org username app_password
- Custom domain example:
$ composer config --global http-basic.example.com username app_password
host
- BitBucket's domain, if empty it's equivalent:bitbucket.org
username
- BitBucket'susername
password
- BitBucket'sapp_password
(generate new one using this link)
{
"repositories": [
{
"type": "composer",
"url": "<github|bitbucket>://<owner>[@<host>]"
}
]
}
github.com
example:
{
"repositories": [
{
"type": "composer",
"url": "github://PiotrPress"
}
]
}
- Custom domain example:
{
"repositories": [
{
"type": "composer",
"url": "github://PiotrPress@example.com"
}
]
}
owner
- GitHub's repositoryowner
host
- API endpoint domain, if empty it's equivalent:github.com
bitbucket.org
example:
{
"repositories": [
{
"type": "composer",
"url": "bitbucket://PiotrPress"
}
]
}
- Custom domain example:
{
"repositories": [
{
"type": "composer",
"url": "bitbucket://PiotrPress@example.com"
}
]
}
owner
- BitBucket'sworkspace
host
- 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.json
If there are many repositories to scan, it may be necessary to increase the process timeout.
- PHP >=
7.4
version. - Composer ^
2.0
version.