licensetorun/php-sdk

Framework-agnostic PHP SDK for Licensetorun.com — activate, validate, swap and check updates for your licensed product. Zero dependencies.

Maintainers

Package info

github.com/licensetorun/php-sdk

pkg:composer/licensetorun/php-sdk

Statistics

Installs: 0

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 12:01:33 UTC


README

A framework-agnostic PHP client for Licensetorun.com. Zero dependencies — just PHP 8.0+, cURL and JSON. Use it in plain PHP, Symfony, Slim, a CLI, or anywhere you don't have the Laravel package.

Install

composer require licensetorun/php-sdk

Or vendor it without Composer — the SDK is two files:

require __DIR__ . '/src/LicenseResult.php';
require __DIR__ . '/src/LicenseClient.php';

Usage

use Licensetorun\LicenseSdk\LicenseClient;

$license = new LicenseClient([
    'api_base'    => 'https://licensetorun.com',
    'product_id'  => 'PRODUCT-PUBLIC-UUID',  // from the product page in the dashboard
    'license_key' => 'CUSTOMER-KEY',
    'instance'    => 'customer-instance',    // optional — defaults to gethostname()
]);

// Activate once (consumes a seat):
$result = $license->activate();
if ($result->failed()) {
    exit('Activation failed: ' . $result->message());
}

// Gate a feature:
if ($license->isValid()) {
    // ...licensed feature...
}

// Inspect the full result:
$result = $license->validate();
$result->ok();                 // bool
$result->error();              // e.g. "license_expired", "ip_not_allowed"
$result->get('license.status');// dot-access into the response

Move a seat to a new server

$license->swap('old-server.com', 'new-server.com');

Check for updates

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

Notes

  • Every method returns a LicenseResult and never throws on HTTP/network errors — a failed request comes back as error() === 'network_error'.
  • validate() is not cached here (unlike the Laravel package). Call it on a schedule or cache the result yourself (e.g. for a few hours) if you check on every request, so you don't hit the API each time.

MIT licensed.