Skip to content

Commit 2387f01

Browse files
authored
Merge pull request #69 from packagist/vendor-bundles
Vendor setup: add section about vendor bundles
2 parents 142b070 + a8cfe51 commit 2387f01

File tree

1 file changed

+42
-0
lines changed

1 file changed

+42
-0
lines changed

docs/setup-vendor.md

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,48 @@ they keep access to those versions beyond the specified date. If you want to rem
9595
This is useful if your customers buy a license from you for a certain timeframe e.g. a full year and therefore should get
9696
access to all versions that are released within that year.
9797

98+
## Using vendor bundles to manage customer access to packages
99+
100+
Vendor bundles allow you to group packages and grant multiple customers access to the same packages. Instead of having to
101+
grant customers access to every package individually, you grant them access to a vendor bundle, and they will automatically
102+
receive access to all packages in the bundle. Adding additional packages to that bundle will then automatically grant
103+
all customers with access to the bundle access to these packages as well.
104+
105+
Vendor bundles can be managed on the Vendor Bundles section from the Vendor tab, and they can be assigned to customers on the bundle section of a customer.
106+
107+
Vendor bundles can also be created and customer access can be granted via our API using our [API client](https://github.com/packagist/private-packagist-api-client) with the following code snippet:
108+
109+
```
110+
<?php
111+
112+
require_once __DIR__ . '/vendor/autoload.php';
113+
114+
$customerId = 42;
115+
116+
$client = new \PrivatePackagist\ApiClient\Client();
117+
$client->authenticate('api-token', 'api-secret');
118+
119+
// Create a vendor bundle if not yet existing
120+
$vendorBundle = $client->vendorBundles()->create('Acme Bundle');
121+
122+
// Add one or more packages to the vendor bundle
123+
$packages = [
124+
[
125+
'name' => 'acme/website',
126+
'versionConstraint' => '^1.0 | ^2.0', // optional version constraint to limit updates the customer receives
127+
'minimumAccessibleStability' => 'beta', // optional stability to restrict customers to specific package version stabilities like alpha, beta, or RC
128+
],
129+
];
130+
$packages = $client->vendorBundles()->packages()->addOrEditPackages($vendorBundle['id'], $packages);
131+
132+
// Grant a customer access to the vendor bundle and all its packages
133+
$client->customers()->vendorBundles()->addOrEditVendorBundle(
134+
$customerId,
135+
$vendorBundle['id'],
136+
(new \DateTime('+1 year'))->format('c'), // optional expiration date to limit updates the customer receives
137+
);
138+
```
139+
98140
## Adding a package to an existing Composer project
99141

100142
To install a package named "acme-company/api" into an existing project, the following steps are required:

0 commit comments

Comments
 (0)