piotrpress / private-composer
This composer plugin adds github and bitbucket protocols support to Composer in order to simplify private repositories handling.
Installs: 643
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 1
Type:composer-plugin
pkg:composer/piotrpress/private-composer
Requires
- php: >=7.4
- composer-plugin-api: ^2.0
- piotrpress/remoter: ^1.0
- piotrpress/streamer: ^1.0
README
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.
Example
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": "*"
}
}
Installation
- 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
Authentication
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
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 token
host- GitHub's domain, if empty it's equivalent:github.comusername- alwaysx-oauth-basicpassword- GitHub'stoken(generate new one using this link)
BitBucket
bitbucket.orgexample:
$ 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.orgusername- BitBucket'susernamepassword- BitBucket'sapp_password(generate new one using this link)
Usage in composer.json file
{
"repositories": [
{
"type": "composer",
"url": "<github|bitbucket>://<owner>[@<host>]"
}
]
}
GitHub
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
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
Usage as a command
$ composer packages <github|bitbucket>://<owner>[@<host>]
Command's output is a valid packages.json file content.
Example
$ composer packages github://PiotrPress > packages.json
Note
If there are many repositories to scan, it may be necessary to increase the process timeout.
Requirements
- PHP >=
7.4version. - Composer ^
2.0version.