PHPackages                             getkeymanager/laravel-sdk - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Validation &amp; Sanitization](/categories/validation)
4. /
5. getkeymanager/laravel-sdk

ActiveLibrary[Validation &amp; Sanitization](/categories/validation)

getkeymanager/laravel-sdk
=========================

Official Laravel SDK for License Management Platform - Elegant license validation, activation, and management for Laravel applications

3.2.0(2mo ago)0132—3.4%MITPHPPHP ^8.1 || ^8.2 || ^8.3

Since Jan 24Pushed 2mo agoCompare

[ Source](https://github.com/getkeymanager/laravel-sdk)[ Packagist](https://packagist.org/packages/getkeymanager/laravel-sdk)[ Docs](https://getkeymanager.com)[ RSS](/packages/getkeymanager-laravel-sdk/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (10)Dependencies (8)Versions (13)Used By (0)

KeyManager - License Manager Laravel SDK
========================================

[](#keymanager---license-manager-laravel-sdk)

For KeyManager ().

[![Latest Version](https://camo.githubusercontent.com/c05093e76501ee82e6f659c4e71d1932c3556c332b7388e578890e0eae80cfed/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6765746b65796d616e616765722f6c61726176656c2d73646b2e737667)](https://packagist.org/packages/getkeymanager/laravel-sdk)[![License](https://camo.githubusercontent.com/e0089bb4118f6c8061f683b8ce28baea222c7e5dd2462f0062d1dbc47e91e2d9/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f6765746b65796d616e616765722f6c61726176656c2d73646b2e737667)](https://packagist.org/packages/getkeymanager/laravel-sdk)[![Total Downloads](https://camo.githubusercontent.com/56286ca1b1548378ba77db515240ec1433c2ce9a1d5486fc5159a93f304ac16f/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6765746b65796d616e616765722f6c61726176656c2d73646b2e737667)](https://packagist.org/packages/getkeymanager/laravel-sdk)

**Version: 3.0.0** - Identifier-first with configuration inheritance and offline-first validation!

Official Laravel SDK for [License Management Platform](https://getkeymanager.com). Elegant license validation, activation, and management for Laravel applications with built-in middleware, Artisan commands, and facade support.

Features
--------

[](#features)

- 🚀 **Easy Integration** - Service provider auto-discovery, zero configuration
- 🧐 **Laravel-Native** - Facades, middleware, Artisan commands
- 🔐 **Route Protection** - Protect routes with license validation middleware
- 🎯 **Feature Flags** - Feature-gate middleware for license-based features
- 🔨 **CLI Commands** - Artisan commands for license operations
- 📏 **Full Logging** - Optional Laravel logging integration
- ⚡ **Session Caching** - Automatic session-based caching
- 🔄 **Laravel 10, 11, 12** - Multi-version compatibility
- **NEW v3.0.0:** Configuration inheritance, offline-first validation, identifier parameters, type-safe DTOs

New in v3.0.0 - BREAKING CHANGES
--------------------------------

[](#new-in-v300---breaking-changes)

- ✅ **Mandatory Identifier Parameter** - Use `default_identifier` in config or pass explicitly
- ✅ **Configuration Inheritance** - Set `license_file_path`, `default_identifier`, enhanced `public_key_file` in config
- ✅ **Offline-First Validation** - Automatically validates against cached .lic file before API
- ✅ **Type-Safe Methods** - Import and use Constants: `ValidationType`, `IdentifierType`
- ✅ **Enhanced Error Messages** - Actionable errors with documentation links
- ⚠️ **MIGRATION REQUIRED:** See migration guide in config file

Requirements
------------

[](#requirements)

- PHP 8.1 or higher
- Laravel 10.x, 11.x, or 12.x
- ext-json, ext-openssl, ext-curl

Installation
------------

[](#installation)

Install via Composer:

```
composer require getkeymanager/laravel-sdk
```

### Publish Configuration (Optional)

[](#publish-configuration-optional)

```
php artisan vendor:publish --tag=getkeymanager-config
```

This creates `config/getkeymanager.php`.

### Environment Configuration

[](#environment-configuration)

Add to your `.env` file:

```
LICENSE_MANAGER_API_KEY=your-api-key-here
LICENSE_MANAGER_BASE_URL=https://api.getkeymanager.com
LICENSE_MANAGER_ENVIRONMENT=production
LICENSE_MANAGER_VERIFY_SIGNATURES=true
LICENSE_MANAGER_PUBLIC_KEY="-----BEGIN PUBLIC KEY-----\n...\n-----END PUBLIC KEY-----"
```

Quick Start
-----------

[](#quick-start)

### Configuration Setup

[](#configuration-setup)

Publish and configure in `config/getkeymanager.php`:

```
'license_file_path' => env('LICENSE_FILE_PATH', 'storage/licenses'),
'default_identifier' => env('DEFAULT_IDENTIFIER', null), // or 'example.com'
'public_key_file' => storage_path('keys/public.pem'),
```

### Using the Facade

[](#using-the-facade)

```
use GetKeyManager\Laravel\Facades\GetKeyManager;
use GetKeyManager\SDK\Constants\ValidationType;

// Validate with auto-generated identifier
$result = GetKeyManager::validateLicense('XXXXX-XXXXX-XXXXX-XXXXX');

// Or validate with specific identifier
$result = GetKeyManager::validateLicense(
    'XXXXX-XXXXX-XXXXX-XXXXX',
    'example.com',  // Domain identifier
    null,           // Will use config's public key
    ValidationType::OFFLINE_FIRST  // Try cache first
);

if ($result['success']) {
    echo "License is valid!";
}

// Activate a license
$result = GetKeyManager::activateLicense(
    'XXXXX-XXXXX-XXXXX-XXXXX',
    'workstation-01'  // Required identifier
);

// Check a feature (fail-secure: returns false on any error)
if (GetKeyManager::checkFeature('XXXXX-XXXXX-XXXXX-XXXXX', 'advanced-features')) {
    echo "Feature is enabled!";
}
```

### Using Dependency Injection

[](#using-dependency-injection)

```
use GetKeyManager\Laravel\GetKeyManagerClient;

class LicenseController extends Controller
{
    public function validate(GetKeyManagerClient $license)
    {
        $result = $license->validateLicense(request('license_key'));

        return response()->json($result);
    }
}
```

Middleware Protection
---------------------

[](#middleware-protection)

### Protect Routes with License Validation

[](#protect-routes-with-license-validation)

```
// In routes/web.php
Route::middleware(['license.validate'])->group(function () {
    Route::get('/dashboard', [DashboardController::class, 'index']);
    Route::get('/settings', [SettingsController::class, 'index']);
});

// Validate against a specific product
Route::get('/premium', function () {
    return view('premium');
})->middleware('license.validate:product-uuid-here');
```

### Feature-Gated Routes

[](#feature-gated-routes)

```
// Require a specific feature to be enabled
Route::get('/advanced-analytics', function () {
    return view('analytics.advanced');
})->middleware('license.feature:advanced-analytics');

// Chain middlewares
Route::middleware(['license.validate', 'license.feature:reporting'])
    ->group(function () {
        Route::get('/reports', [ReportController::class, 'index']);
    });
```

### Accessing License Data in Controllers

[](#accessing-license-data-in-controllers)

The middleware attaches license data to the request:

```
class DashboardController extends Controller
{
    public function index(Request $request)
    {
        $licenseData = $request->get('_license_data');
        $customerEmail = $licenseData['customer_email'] ?? 'Unknown';

        return view('dashboard', compact('licenseData', 'customerEmail'));
    }
}
```

### Custom Redirect on Validation Failure

[](#custom-redirect-on-validation-failure)

Configure in `config/getkeymanager.php`:

```
'middleware' => [
    'redirect_to' => '/license-required',
    'cache_in_session' => true,
],
```

### Providing License Key

[](#providing-license-key)

The middleware accepts license keys from:

1. Header: `X-License-Key`
2. Query parameter: `?license_key=XXXXX`
3. Request body: `license_key` field
4. Session (cached from previous validation)

Artisan Commands
----------------

[](#artisan-commands)

### Validate a License

[](#validate-a-license)

```
php artisan license:validate XXXXX-XXXXX-XXXXX-XXXXX

# With options
php artisan license:validate XXXXX-XXXXX-XXXXX-XXXXX \
    --hardware-id=custom-hwid \
    --product-id=product-uuid

# JSON output
php artisan license:validate XXXXX-XXXXX-XXXXX-XXXXX --json
```

### Activate a License

[](#activate-a-license)

```
php artisan license:activate XXXXX-XXXXX-XXXXX-XXXXX

# With custom hardware ID
php artisan license:activate XXXXX-XXXXX-XXXXX-XXXXX \
    --hardware-id=server-001 \
    --name="Production Server"

# Domain-based activation
php artisan license:activate XXXXX-XXXXX-XXXXX-XXXXX \
    --domain=example.com
```

### Deactivate a License

[](#deactivate-a-license)

```
# Deactivate by hardware ID
php artisan license:deactivate XXXXX-XXXXX-XXXXX-XXXXX \
    --hardware-id=server-001

# Deactivate specific activation
php artisan license:deactivate XXXXX-XXXXX-XXXXX-XXXXX \
    --activation-id=activation-uuid

# Deactivate all activations
php artisan license:deactivate XXXXX-XXXXX-XXXXX-XXXXX --all
```

Advanced Usage
--------------

[](#advanced-usage)

### Creating Licenses

[](#creating-licenses)

```
use GetKeyManager\Laravel\Facades\GetKeyManager;

$result = GetKeyManager::createLicenseKeys(
    'product-uuid',
    'generator-uuid',
    [
        ['activation_limit' => 5, 'validity_days' => 365],
        ['activation_limit' => 1, 'validity_days' => 30]
    ],
    'customer@example.com'
);
```

### Offline Validation

[](#offline-validation)

```
// Read offline license file
$offlineLicense = file_get_contents('license.lic');

$result = GetKeyManager::validateOfflineLicense($offlineLicense, [
    'hardwareId' => GetKeyManager::generateHardwareId()
]);
```

### Getting License Details

[](#getting-license-details)

```
$details = GetKeyManager::getLicenseDetails('XXXXX-XXXXX-XXXXX-XXXXX');

// Get activations
$activations = GetKeyManager::getLicenseActivations('XXXXX-XXXXX-XXXXX-XXXXX');
```

### License Lifecycle Management

[](#license-lifecycle-management)

```
// Suspend a license
GetKeyManager::suspendLicense('XXXXX-XXXXX-XXXXX-XXXXX');

// Resume a suspended license
GetKeyManager::resumeLicense('XXXXX-XXXXX-XXXXX-XXXXX');

// Revoke a license (permanent)
GetKeyManager::revokeLicense('XXXXX-XXXXX-XXXXX-XXXXX');
```

### Working with Metadata

[](#working-with-metadata)

```
// Get license metadata
$metadata = GetKeyManager::getLicenseMetadata('XXXXX-XXXXX-XXXXX-XXXXX');

// Update metadata
GetKeyManager::updateLicenseMetadata('XXXXX-XXXXX-XXXXX-XXXXX', [
    'server_name' => 'Production 1',
    'deployment_date' => now()->toDateString()
]);

// Delete specific metadata key
GetKeyManager::deleteLicenseMetadata('XXXXX-XXXXX-XXXXX-XXXXX', 'server_name');
```

### Telemetry

[](#telemetry)

```
GetKeyManager::sendTelemetry('XXXXX-XXXXX-XXXXX-XXXXX', [
    'event' => 'feature_used',
    'feature_name' => 'export_pdf',
    'usage_count' => 1,
    'timestamp' => now()->toIso8601String()
]);
```

### Downloadables

[](#downloadables)

```
// Get product downloadables
$downloads = GetKeyManager::getDownloadables('product-uuid');

// Get download URL (authenticated)
$url = GetKeyManager::getDownloadUrl('downloadable-uuid', 'XXXXX-XXXXX-XXXXX-XXXXX');

// Redirect user to download
return redirect($url['data']['download_url']);
```

Configuration Reference
-----------------------

[](#configuration-reference)

Full configuration in `config/getkeymanager.php`:

```
return [
    'api_key' => env('LICENSE_MANAGER_API_KEY'),
    'base_url' => env('LICENSE_MANAGER_BASE_URL', 'https://api.getkeymanager.com'),
    'environment' => env('LICENSE_MANAGER_ENVIRONMENT', 'production'),
    'verify_signatures' => env('LICENSE_MANAGER_VERIFY_SIGNATURES', true),
    'public_key' => env('LICENSE_MANAGER_PUBLIC_KEY'),
    'timeout' => env('LICENSE_MANAGER_TIMEOUT', 30),
    'cache_enabled' => env('LICENSE_MANAGER_CACHE_ENABLED', true),
    'cache_ttl' => env('LICENSE_MANAGER_CACHE_TTL', 300),
    'retry_attempts' => env('LICENSE_MANAGER_RETRY_ATTEMPTS', 3),
    'retry_delay' => env('LICENSE_MANAGER_RETRY_DELAY', 1000),

    'middleware' => [
        'redirect_to' => '/license-required',
        'cache_in_session' => true,
        'session_key' => 'license_validation',
    ],

    'logging' => [
        'enabled' => env('LICENSE_MANAGER_LOGGING', false),
        'channel' => env('LICENSE_MANAGER_LOG_CHANNEL', 'stack'),
    ],
];
```

Error Handling
--------------

[](#error-handling)

```
use GetKeyManager\Laravel\Facades\GetKeyManager;
use Exception;

try {
    $result = GetKeyManager::validateLicense($licenseKey);

    if (!$result['success']) {
        // Handle validation failure
        $errorCode = $result['code'] ?? 0;
        $message = $result['message'] ?? 'Validation failed';

        // Handle specific error codes
        if ($errorCode === 4003) {
            return "License has expired";
        }
    }
} catch (Exception $e) {
    // Handle API errors
    Log::error('License validation error: ' . $e->getMessage());
    return "Unable to validate license";
}
```

Testing
-------

[](#testing)

```
use GetKeyManager\Laravel\Facades\GetKeyManager;

class FeatureTest extends TestCase
{
    public function test_license_validation()
    {
        $result = GetKeyManager::validateLicense('test-license-key');

        $this->assertTrue($result['success']);
        $this->assertEquals('active', $result['data']['status']);
    }
}
```

### Mocking in Tests

[](#mocking-in-tests)

```
use GetKeyManager\Laravel\Facades\GetKeyManager;

public function test_protected_route()
{
    GetKeyManager::shouldReceive('validateLicense')
        ->once()
        ->andReturn([
            'success' => true,
            'data' => ['status' => 'active']
        ]);

    $response = $this->get('/protected-route');
    $response->assertStatus(200);
}
```

API Reference
-------------

[](#api-reference)

The Laravel SDK proxies all methods from the base PHP SDK. See the [full API reference](https://docs.getkeymanager.com/sdks/php/api-reference).

### Core Methods

[](#core-methods)

- `validateLicense(string $licenseKey, array $options = []): array`
- `activateLicense(string $licenseKey, array $options = []): array`
- `deactivateLicense(string $licenseKey, array $options = []): array`
- `checkFeature(string $licenseKey, string $featureName): array`
- `validateOfflineLicense($offlineLicenseData, array $options = []): array`

### License Management

[](#license-management)

- `createLicenseKeys(string $productUuid, string $generatorUuid, array $licenses, ?string $customerEmail, array $options = []): array`
- `updateLicenseKey(string $licenseKey, array $options = []): array`
- `getLicenseDetails(string $licenseKey): array`
- `getLicenseActivations(string $licenseKey): array`
- `suspendLicense(string $licenseKey): array`
- `resumeLicense(string $licenseKey): array`
- `revokeLicense(string $licenseKey): array`

### Utilities

[](#utilities)

- `generateHardwareId(): string`
- `generateUuid(): string`

Examples
--------

[](#examples)

See the [examples directory](./examples) for complete working examples.

Support
-------

[](#support)

- **Website**:
- **Documentation**:
- **API Reference**:
- **Issues**:
- **Email**:

License
-------

[](#license)

This SDK is open-sourced software licensed under the [MIT license](LICENSE).

Related
-------

[](#related)

- [Base PHP SDK](https://github.com/getkeymanager/php-sdk)
- [CodeIgniter SDK](https://github.com/getkeymanager/codeigniter-sdk)
- [License Management Platform](https://getkeymanager.com)

###  Health Score

45

—

FairBetter than 92% of packages

Maintenance90

Actively maintained with recent releases

Popularity14

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity56

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 50% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~2 days

Total

12

Last Release

82d ago

Major Versions

1.0 → 2.02026-01-24

2.7 → 3.0.02026-02-05

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/47470909?v=4)[vandanafuletra](/maintainers/vandanafuletra)[@vandanafuletra](https://github.com/vandanafuletra)

---

Top Contributors

[![palzinllc](https://avatars.githubusercontent.com/u/224397079?v=4)](https://github.com/palzinllc "palzinllc (1 commits)")[![vandanafuletra](https://avatars.githubusercontent.com/u/47470909?v=4)](https://github.com/vandanafuletra "vandanafuletra (1 commits)")

---

Tags

laravelvalidationlicenselaravel-packagelicense-managementDRMactivationlicensingsoftware licensing

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StyleLaravel Pint

Type Coverage Yes

### Embed Badge

![Health badge](/badges/getkeymanager-laravel-sdk/health.svg)

```
[![Health](https://phpackages.com/badges/getkeymanager-laravel-sdk/health.svg)](https://phpackages.com/packages/getkeymanager-laravel-sdk)
```

###  Alternatives

[wendelladriel/laravel-validated-dto

Data Transfer Objects with validation for Laravel applications

759569.4k13](/packages/wendelladriel-laravel-validated-dto)[proengsoft/laravel-jsvalidation

Validate forms transparently with Javascript reusing your Laravel Validation Rules, Messages, and FormRequest

1.1k2.3M49](/packages/proengsoft-laravel-jsvalidation)[axlon/laravel-postal-code-validation

Worldwide postal code validation for Laravel and Lumen

3853.3M1](/packages/axlon-laravel-postal-code-validation)[galahad/laravel-addressing

Laravel package providing addressing functionality

70316.6k](/packages/galahad-laravel-addressing)[illuminatech/validation-composite

Allows uniting several validation rules into a single one for easy re-usage

184485.5k](/packages/illuminatech-validation-composite)[romegasoftware/laravel-schema-generator

Generate TypeScript Zod validation schemas from Laravel validation rules

288.2k](/packages/romegasoftware-laravel-schema-generator)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
