licensetorun/laravel-license-client

Drop-in Laravel client for Licensetorun.com — activate, validate and auto-update your product against the licensing API.

Maintainers

Package info

github.com/licensetorun/laravel-license-client

pkg:composer/licensetorun/laravel-license-client

Statistics

Installs: 1

Dependents: 0

Suggesters: 0

Stars: 0

Open Issues: 0

v1.0.0 2026-06-18 02:13 UTC

This package is auto-updated.

Last update: 2026-06-18 11:54:29 UTC


README

A drop-in Laravel client for Licensetorun.com. Add your product id and license key, and the package handles activation, cached validation, seat swapping, and update checks against the licensing API.

Install

composer require licensetorun/laravel-license-client
php artisan vendor:publish --tag=licensing-config

Set your credentials in .env:

LICENSING_API_BASE=https://licensetorun.com
LICENSING_PRODUCT_ID=your-product-public-uuid   # from the product page in the dashboard
LICENSING_KEY=CUSTOMER-LICENSE-KEY

LICENSING_KEY is the customer's key. In a multi-tenant app you'll usually store each tenant's key in your DB and pass it per-call instead of via .env (see below).

Usage

use Licensetorun\LicenseClient\Facades\License;

// One-time, when the customer enters their key:
$result = License::activate();
if ($result->failed()) {
    return back()->withErrors($result->message());
}

// Anywhere you need to gate a feature (cached — cheap to call often):
if (License::isValid()) {
    // ...licensed feature...
}

// Full result inspection:
$result = License::validate();
$result->ok();                 // bool
$result->error();              // e.g. "license_expired", "ip_not_allowed"
$result->license();            // ['status' => 'active', 'expires_at' => ..., 'activations_used' => 1, ...]

Gate routes with middleware

Route::middleware('licensed')->group(function () {
    Route::get('/premium', PremiumController::class);
});

Configure what happens when unlicensed in config/licensing.php (gate.abort_status or gate.redirect_route).

Move a license to a new server

License::swap('old-server.com', 'new-server.com');

Auto-updates / "is there a newer version?"

$update = License::checkForUpdate(currentVersion: '1.2.0');

if ($update->get('update_available')) {
    $version     = $update->get('version');
    $downloadUrl = $update->get('download_url'); // short-lived signed URL
}

Artisan

php artisan license:activate CUSTOMER-KEY
php artisan license:status --fresh

Multi-tenant apps

Build a client per tenant instead of using the global facade:

use Licensetorun\LicenseClient\LicenseClient;

$client = new LicenseClient(array_merge(config('licensing'), [
    'license_key' => $tenant->license_key,
    'instance'    => $tenant->domain,   // one seat per tenant domain
]));

$client->validate();

How it works

  • Identity: each install is an instance (defaults to your APP_URL host; override per-tenant). Seats are counted per instance.
  • validate() / isValid() cache the result for config('licensing.cache.ttl') (12h by default) so they don't hit the API on every request.
  • Every method returns a LicenseResult and never throws — network errors surface as ->error() === 'network_error'.

MIT licensed.