licensetorun/laravel-license-client 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

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_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.

统计信息

  • 总下载量: 0
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 3
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-06-18

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固