licensetorun/laravel-license-client
Composer 安装命令:
composer require licensetorun/laravel-license-client
包简介
Drop-in Laravel client for Licensetorun.com — activate, validate and auto-update your product against the licensing API.
README 文档
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_KEYis 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_URLhost; override per-tenant). Seats are counted per instance. validate()/isValid()cache the result forconfig('licensing.cache.ttl')(12h by default) so they don't hit the API on every request.- Every method returns a
LicenseResultand never throws — network errors surface as->error() === 'network_error'.
MIT licensed.
统计信息
- 总下载量: 0
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 2
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2026-06-18