About
A simple library that automatically creates a local packagist for private repositories hosted on BitBucket., (*1)
The project has two main functions:, (*2)
- Creates a json file with auto-generated repositories (vcs) from a user or team on BitBucket that can be merged into an existing composer.json file. This is almost like having a local version of a Private Packagist.
- Takes the auto-generated json file to also create a static composer repository (through Satis) that can be uploaded to a server and served to other projects.
Installation
composer require vincentholmblad/bitbucket-packagist
, (*3)
Add these lines to composer.json after you've installed the package., (*4)
// See https://bitbucket.org/account/user/<team or user>/api
// There you can create an OAuth consumer
// Make sure the consumer has access to read repositories
"config": {
"bitbucket_consumer_key": "key",
"bitbucket_consumer_secret": "secret",
"bitbucket_team": "team or user"
},
// Merges scripts and repositories from the user or team
extra: {
"merge-plugin": {
"include": [
"./vendor/vincentholmblad/bitbucket-packagist/bitbucket_packagist_scripts.json",
"./vendor/vincentholmblad/bitbucket-packagist/packages.json"
],
"merge-scripts": true
}
}
Then run composer run-script bb_composer_packages
whenver you need to update your local packagist., (*5)
NOT RECOMMENDED! If you want to automatically update the local packagist with any changes then also include this to your composer.json. This will make the process of updating and installing new packages very slow as the process has to check load composer.json files from all your private repositories to build the packages.json file., (*6)
// Automatically update local private packagist
"scripts": {
"pre-update-cmd": [
"@bb_composer_packages"
],
"pre-install-cmd": [
"@bb_composer_packages"
]
}
If you want to upload the result to a server then run composer run-script bb_composer_packages
and upload the resulting folder ("./dist/" inside the package directory in vendor) to your hosting-service of choice. You can then include your new private packagist with this code in your composer.json., (*7)
// Load repositores from private packagist
"repositories": [
{
"type": "composer",
"url": "link to uploaded position"
}
]
Sidenote for repositories
Make sure that every repository that you want to include has its own composer.json with at least a name and a version field. This namefield should match the name of the repository., (*8)
An example below., (*9)
{
"name": "your-shorthand/repo-name",
"version": "master"
}