- PHP >= 5.6
- Guzzle library,
Via Composer:
$ composer require private-packagist/api-client php-http/guzzle6-adapter
Why do you need to require php-http/guzzle6-adapter
? We are decoupled from any HTTP messaging client with help by HTTPlug, so you can pick an HTTP client of your choice, guzzle is merely a recommendation.
<?php
// This file is generated by Composer
require_once __DIR__ . '/vendor/autoload.php';
$client = new \PrivatePackagist\ApiClient\Client();
$client->authenticate('api-token', 'api-secret');
$packages = $client->packages()->all();
From $client
object, you can access the full Private Packagist API.
Full documentation can be found in the Private Packagist documentation.
$client->organization()->sync();
$customers = $client->customers()->all();
Returns an array of customers.
$customerId = 42;
$customer = $client->customers()->show($customerId);
Returns a single customer.
$customer = $client->customers()->create('New customer name');
Returns the customer.
$customerId = 42;
$client->customers()->remove($customerId);
$packages = $client->customers()->listPackages();
Returns an array of customer packages.
$customerId = 42;
$packages = [
[
'name' => 'acme-website/package',
'versionConstraint' => '^1.0 | ^2.0', // optional version constraint to limit updades the customer receives
'expirationDate' => (new \DateTime())->add(new \DateInterval('P1Y'))->format('c'), // optional expiration date to limit updades the customer receives
],
];
$packages = $client->customers()->addOrUpdatePackages($customerId, $packages);
Returns an array of added customer packages.
$customerId = 42;
$packageName = 'acme-website/package';
$client->customers()->removePackage($customerId, $packageName);
$customerId = 42;
$confirmation = [
'IConfirmOldTokenWillStopWorkingImmediately' => true,
];
$composerRepository = $client->customers()->regenerateToken($customerId, $confirmation);
Returns the updated Composer repository.
$filters = [
'origin' => \PrivatePackagist\ApiClient\Api\Packages::ORIGIN_PRIVATE, // optional filter to only receive packages that can be added to customers
];
$packages = $client->packages()->all($filters);
Returns an array of packages.
private-packagist/api-client
is licensed under the MIT License