pkgdist / pkgdist-client
Client for the PKG-DIST api
Requires
- php: ^8.2
- composer/composer: *
- illuminate/support: ^10|^11|^12|^13
Requires (Dev)
- orchestra/testbench: ^9.0|^10.0|^11.0
- pestphp/pest: ^2.34|^3.0|^4.0
- pestphp/pest-plugin-laravel: ^2.4|^3.0|^4.0
- spatie/laravel-ray: ^1.36
README
PHP client for the PKG-DIST API. Built for Laravel — auto-discovers, exposes a small Package class, and adds an Http::pkgdist() macro.
Requirements
- PHP
^8.2 - Laravel
^10,^11,^12, or^13
Installation
composer require pkgdist/pkgdist-client
The service provider is auto-discovered. No manual registration needed.
Configuration
Set the endpoint base host in your .env:
PKGDIST_CLIENT_ENDPOINT=pkg-dist.com
Optionally publish the config to override it directly:
php artisan vendor:publish --tag=config --provider="Pkgdist\Client\ClientServiceProvider"
// config/pkgdist-client.php return [ 'endpoint' => env('PKGDIST_CLIENT_ENDPOINT'), ];
Usage
Loading a package
use Pkgdist\Client\Package; $package = Package::load( package: 'vendor/package-name', slug: 'your-tenant-slug', token: 'your-license-token', );
The slug is combined with the configured endpoint to form the API base URL — e.g. https://your-tenant-slug.pkg-dist.com/api.
Fetching changelogs
changelogs() returns an Illuminate\Support\Collection of Changelog objects:
$changelogs = $package->changelogs(); foreach ($changelogs as $changelog) { echo $changelog->version; // e.g. "1.2.0" echo $changelog->content; // markdown release notes echo $changelog->created_at; // ISO-8601 timestamp }
Because it's a Laravel Collection, you can chain the usual helpers:
$latest = $package->changelogs()->first(); $recent = $package->changelogs() ->sortByDesc('created_at') ->take(5);
The Http::pkgdist() macro
The service provider registers a macro on Laravel's HTTP client that pre-configures the base URL, so you can make ad-hoc requests against the API without instantiating Package:
use Illuminate\Support\Facades\Http; $response = Http::pkgdist() ->withToken($licenseToken) ->get('some/endpoint');
Testing
composer test
Tests use Pest and Orchestra Testbench.
License
GPL-3.0-only. See LICENSE.