PHPackages                             akira/laravel-license-core - 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. [Authentication &amp; Authorization](/categories/authentication)
4. /
5. akira/laravel-license-core

ActiveLibrary[Authentication &amp; Authorization](/categories/authentication)

akira/laravel-license-core
==========================

Modern, secure and extensible licensing engine for Laravel applications. The Core package provides the full domain logic, models, pipelines, value objects, builders and actions required to implement a complete licensing system inside Laravel — without forcing any UI, API or dashboard layer.

1.x-dev(4mo ago)511[1 PRs](https://github.com/akira-io/laravel-license-core/pulls)1MITPHPPHP ^8.4CI passing

Since Jan 8Pushed 1mo ago1 watchersCompare

[ Source](https://github.com/akira-io/laravel-license-core)[ Packagist](https://packagist.org/packages/akira/laravel-license-core)[ Docs](https://github.com/akira/laravel-license-core)[ GitHub Sponsors](https://github.com/kidiatoliny)[ RSS](/packages/akira-laravel-license-core/feed)WikiDiscussions 1.x Synced 1mo ago

READMEChangelogDependencies (17)Versions (2)Used By (1)

Laravel License
===============

[](#laravel-license)

[![Latest Version on Packagist](https://camo.githubusercontent.com/1b765f90bee38804f23df923cda0b9420fa473010c0893cb241787e9ad156e1c/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f616b6972612f6c61726176656c2d6c6963656e73652d636f72652e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/akira/laravel-license-core)[![GitHub Tests Action Status](https://camo.githubusercontent.com/5689abe502766e9c7f58f63baad3480eda5c65961405b16e278994b8387742f5/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f616b6972612f6c61726176656c2d6c6963656e73652d636f72652f72756e2d74657374732e796d6c3f6272616e63683d6d61696e266c6162656c3d7465737473267374796c653d666c61742d737175617265)](https://github.com/akira/laravel-license-core/actions?query=workflow%3Arun-tests+branch%3Amain)[![GitHub Code Style Action Status](https://camo.githubusercontent.com/1649648c821becdd1e2d6d8d67b774e0e1933f044554f6d033c9403c67329711/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f616b6972612f6c61726176656c2d6c6963656e73652d636f72652f6669782d7068702d636f64652d7374796c652d6973737565732e796d6c3f6272616e63683d6d61696e266c6162656c3d636f64652532307374796c65267374796c653d666c61742d737175617265)](https://github.com/akira/laravel-license-core/actions?query=workflow%3A%22Fix+PHP+code+style+issues%22+branch%3Amain)[![Total Downloads](https://camo.githubusercontent.com/5fd8b860bc1a4fc09f02560f92d37be4cd574e148a2c2eebdacd02fb870948b9/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f616b6972612f6c61726176656c2d6c6963656e73652d636f72652e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/akira/laravel-license-core)

A modern, secure and extensible licensing engine for Laravel applications. This package provides the complete domain logic, models, and business rules required to implement a full-featured licensing system inside Laravel applications.

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

[](#requirements)

- PHP 8.4 or higher
- Laravel 12.x or higher

Features
--------

[](#features)

- Multiple license types: Lifetime, Annual, Subscription, Trial, and Credits-based
- License status management: Active, Expired, Suspended, and Revoked
- Activation tracking with domain, machine hash, IP, and user agent
- Usage monitoring with consumed units and limits
- Event logging for complete audit trail
- Grace period support for expired licenses
- Encrypted metadata storage
- Comprehensive configuration system for all business rules
- Configurable table names and models
- Dynamic pipeline stage loading
- Custom key generation formats (UUID and sequential)
- Full factory support for testing
- 100% test coverage (438 tests, 764 assertions)

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

[](#installation)

You can install the package via composer:

```
composer require akira/laravel-license-core
```

You can publish and run the migrations with:

```
php artisan vendor:publish --tag="laravel-license-core-migrations"
php artisan migrate
```

You can publish the config file with:

```
php artisan vendor:publish --tag="laravel-license-core-config"
```

This is the contents of the published config file:

```
return [
    'tables' => [
        'licenses' => 'licenses',
        'activations' => 'license_activations',
        'usages' => 'license_usages',
        'events' => 'license_events',
    ],

    'models' => [
        'license' => License::class,
        'activation' => LicenseActivation::class,
        'usage' => LicenseUsage::class,
        'event' => LicenseEvent::class,
    ],
];
```

Usage
-----

[](#usage)

### Using the License Facade

[](#using-the-license-facade)

The simplest way to work with licenses is through the `License` facade:

```
use Akira\LaravelLicense\Facades\License;
use Akira\LaravelLicense\ValueObjects\LicenseData;
use Akira\LaravelLicense\Enums\LicenseType;
use Akira\LaravelLicense\Enums\LicenseStatus;

// Create a license with auto-generated key
$license = License::createWithAutoKey(
    new LicenseData(
        key: '',
        type: LicenseType::ANNUAL,
        status: LicenseStatus::ACTIVE,
        maxActivations: 5,
        maxSeats: 10,
        fallback: false,
        scopes: ['feature:premium'],
        meta: ['customer_email' => 'john@example.com'],
        expiresAt: now()->addYear(),
        graceEndsAt: null,
    )
);

// Validate license usage
$isValid = License::validateUsage(
    key: $license->key,
    machine: 'unique-machine-fingerprint',
    domain: 'example.com',
    activate: true
);

// Validate license for updates
$canUpdate = License::validateUpdate(
    key: $license->key,
    releaseDate: now(),
    domain: 'example.com',
    machine: 'unique-machine-fingerprint'
);

// Consume credits
$success = License::consumeCredits(
    key: $license->key,
    amount: 10
);

// Rotate license key
$newKey = License::rotateKey($license->key);
```

### Creating a License Directly

[](#creating-a-license-directly)

You can also create licenses using the model:

```
use Akira\LaravelLicense\Models\License;
use Akira\LaravelLicense\Enums\LicenseType;
use Akira\LaravelLicense\Enums\LicenseStatus;

$license = License::create([
    'key' => 'XXXX-XXXX-XXXX-XXXX',
    'type' => LicenseType::ANNUAL->value,
    'status' => LicenseStatus::ACTIVE->value,
    'max_activations' => 5,
    'max_seats' => 10,
    'expires_at' => now()->addYear(),
]);
```

### Using Factories

[](#using-factories)

```
// Create a basic license
$license = License::factory()->create();

// Create an active annual license
$license = License::factory()
    ->active()
    ->annual()
    ->create();

// Create a license with grace period
$license = License::factory()
    ->withGracePeriod()
    ->create();

// Create a license with metadata
$license = License::factory()
    ->withMeta(['customer_id' => 123])
    ->create();
```

### License Activation

[](#license-activation)

```
use Akira\LaravelLicense\Models\LicenseActivation;

$activation = LicenseActivation::create([
    'license_id' => $license->id,
    'domain' => 'example.com',
    'machine_hash' => hash('sha256', 'unique-machine-id'),
    'ip' => request()->ip(),
    'user_agent' => request()->userAgent(),
]);

// Using factory
$activation = LicenseActivation::factory()
    ->forLicense($license)
    ->withDomain('example.com')
    ->create();
```

### Usage Tracking

[](#usage-tracking)

```
use Akira\LaravelLicense\Models\LicenseUsage;

$usage = LicenseUsage::create([
    'license_id' => $license->id,
    'consumed_units' => 0,
    'limit' => 1000,
]);

// Check remaining units
$remaining = $usage->remaining(); // 1000

// Consume units
$usage->update(['consumed_units' => 250]);
$remaining = $usage->remaining(); // 750

// Using factory
$usage = LicenseUsage::factory()
    ->forLicense($license)
    ->withLimit(1000)
    ->fresh() // 0 consumed units
    ->create();
```

### Event Logging

[](#event-logging)

```
use Akira\LaravelLicense\Models\LicenseEvent;
use Akira\LaravelLicense\Enums\LicenseEventType;

$event = LicenseEvent::create([
    'license_id' => $license->id,
    'type' => LicenseEventType::ACTIVATED->value,
    'payload' => [
        'ip' => request()->ip(),
        'user_agent' => request()->userAgent(),
    ],
    'created_at' => now(),
]);

// Using factory
$event = LicenseEvent::factory()
    ->forLicense($license)
    ->activated()
    ->withPayload(['user_id' => 123])
    ->create();
```

### Working with License Status

[](#working-with-license-status)

```
// Check if license is expired
if ($license->isExpired()) {
    // Handle expired license
}

// Check if license is in grace period
if ($license->inGracePeriod()) {
    // Show warning to user
}

// Get license status as enum
$status = $license->statusEnum(); // LicenseStatus enum

// Get license type as enum
$type = $license->typeEnum(); // LicenseType enum
```

### Relationships

[](#relationships)

```
// Get all activations for a license
$activations = $license->activations;

// Get all usage records for a license
$usages = $license->usages;

// Get all events for a license
$events = $license->events;

// Get license from activation
$license = $activation->license;
```

### Configuration System

[](#configuration-system)

The package includes a comprehensive configuration system that controls all business rules without code changes. Configuration is centralized in `config/license.php`.

#### Key Configuration Features

[](#key-configuration-features)

**Key Generation**:

```
'key_generation' => [
    'prefix' => 'LIC',           // Key prefix
    'format' => 'uuid',          // 'uuid' or 'sequential'
],
```

**Grace Period**:

```
'grace_period' => [
    'lifetime' => null,          // Days after lifetime expiration
    'annual' => null,            // Days after annual expiration
    'subscription' => 30,        // Days after subscription expiration
    'trial' => 7,                // Days after trial expiration
    'credits' => null,           // Days after credits expiration
],
```

**Abuse Detection**:

```
'abuse_detection' => [
    'enabled' => true,
    'window_minutes' => 10,
    'activation_threshold' => 10,
    'events_to_monitor' => ['activated'],
    'action_on_abuse' => 'log',  // 'log' or 'suspend'
],
```

**Pipeline Configuration**:

```
'pipeline' => [
    'usage' => [
        'resolve_license',
        'status_check',
        'expiration_usage',
        'grace_period',
        'domain_check',
        'machine_check',
        'credits_usage',
        'abuse_heuristics',
    ],
    'update' => [
        'resolve_license',
        'status_check',
        'expiration_usage',
        'grace_period',
        'update_window',
    ],
],
```

**Credits Configuration**:

```
'credits' => [
    'allow_partial_consumption' => false,
    'allow_refund' => false,
],
```

See the [Configuration Documentation](docs/02-configuration.md) for complete details on all configuration options.

### Custom Table Names

[](#custom-table-names)

You can customize table names in the config file:

```
'tables' => [
    'licenses' => 'my_licenses',
    'activations' => 'my_activations',
    'usages' => 'my_usages',
    'events' => 'my_events',
],
```

### Encrypted Metadata

[](#encrypted-metadata)

License metadata is automatically encrypted:

```
$license = License::create([
    'key' => 'XXXX-XXXX-XXXX-XXXX',
    'type' => LicenseType::ANNUAL->value,
    'status' => LicenseStatus::ACTIVE->value,
    'meta' => [
        'customer_email' => 'user@example.com',
        'plan_name' => 'Professional',
        'features' => ['api_access', 'priority_support'],
    ],
]);

// Metadata is automatically encrypted in database
// and decrypted when accessed
$email = $license->meta['customer_email'];
```

Available License Types
-----------------------

[](#available-license-types)

The package includes the following license types through the `LicenseType` enum:

- `LIFETIME` - Permanent license with no expiration
- `ANNUAL` - Annual subscription that expires after one year
- `SUBSCRIPTION` - Recurring subscription-based license
- `TRIAL` - Trial license with limited time period
- `CREDITS` - Credit-based license for usage tracking

Available License Statuses
--------------------------

[](#available-license-statuses)

License statuses are managed through the `LicenseStatus` enum:

- `ACTIVE` - License is active and can be used
- `EXPIRED` - License has passed its expiration date
- `SUSPENDED` - License is temporarily suspended
- `REVOKED` - License has been permanently revoked

Available Event Types
---------------------

[](#available-event-types)

Events are tracked using the `LicenseEventType` enum:

- `CREATED` - License was created
- `ACTIVATED` - License was activated on a device/domain
- `DEACTIVATED` - License was deactivated
- `ROTATED` - License key was rotated
- `REVOKED` - License was revoked
- `USAGE_CONSUMED` - Usage units were consumed
- `EXPIRED` - License expired
- `ABUSE_DETECTED` - Potential abuse was detected

Testing
-------

[](#testing)

Run the test suite:

```
composer test
```

Run tests with coverage:

```
composer test:coverage
```

The package includes **438 tests** with **100% code coverage** across all components:

### Test Coverage

[](#test-coverage)

- **Commands**: LaravelLicenseCommand
- **Enums**: LicenseType, LicenseStatus, LicenseEventType
- **Facades**: License
- **Models**: License, LicenseActivation, LicenseEvent, LicenseUsage
- **Support**: ConfigManager, KeyGenerator
- **Value Objects**: DomainName, LicenseContext, LicenseKey, LicenseMeta, LicenseScopes, MachineFingerprint, UpdateEntitlement, UsageAmount
- **Configuration Objects**: AbuseDetectionConfiguration, CreditsConfiguration, DomainValidationConfiguration, GracePeriodConfiguration, KeyGenerationConfiguration, LicenseTypeConfiguration, PipelineConfiguration
- **Pipeline Stages**: All 9 validation stages with complete coverage

### Additional Test Commands

[](#additional-test-commands)

```
# Run specific test file
./vendor/bin/pest tests/Models/LicenseTest.php

# Run tests in specific directory
./vendor/bin/pest tests/ValueObjects/

# Run with detailed coverage
./vendor/bin/pest --coverage --min=100
```

Documentation
-------------

[](#documentation)

Complete documentation is available in the [docs](docs/) directory:

- [Index](docs/00-index.md) - Documentation index and navigation
- [Installation](docs/01-installation.md) - Installation and setup guide
- [Configuration](docs/02-configuration.md) - Comprehensive configuration reference with all options
- [Models](docs/03-models.md) - Model documentation and relationships
- [Pipelines](docs/04-pipelines.md) - Pipeline architecture and custom stages
- [Usage Guide](docs/05-usage-guide.md) - Comprehensive usage examples and patterns
- [Value Objects](docs/06-value-objects.md) - Immutable domain objects
- [Actions](docs/07-actions.md) - Domain actions and business logic
- [Exceptions](docs/08-exceptions.md) - Exception handling and error cases
- [Testing](docs/09-testing.md) - Comprehensive testing guide and examples
- [Internationalization](docs/10-internationalization.md) - i18n and localization

Changelog
---------

[](#changelog)

Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.

Contributing
------------

[](#contributing)

Please see [CONTRIBUTING](CONTRIBUTING.md) for details.

Security Vulnerabilities
------------------------

[](#security-vulnerabilities)

Please review [our security policy](../../security/policy) on how to report security vulnerabilities.

Credits
-------

[](#credits)

- [kidiatoliny](https://github.com/kidiatoliny)
- [All Contributors](../../contributors)

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

###  Health Score

37

—

LowBetter than 83% of packages

Maintenance85

Actively maintained with recent releases

Popularity10

Limited adoption so far

Community13

Small or concentrated contributor base

Maturity37

Early-stage or recently created project

 Bus Factor1

Top contributor holds 92.3% 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

Unknown

Total

1

Last Release

124d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/c42e59ca0b3864a382dc0c3e290f8cf7d75bbe3eab10a3af0f71d5785f89d0bc?d=identicon)[kidiatoliny](/maintainers/kidiatoliny)

---

Top Contributors

[![kidiatoliny](https://avatars.githubusercontent.com/u/48266788?v=4)](https://github.com/kidiatoliny "kidiatoliny (36 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (2 commits)")[![github-actions[bot]](https://avatars.githubusercontent.com/in/15368?v=4)](https://github.com/github-actions[bot] "github-actions[bot] (1 commits)")

---

Tags

laravelakiralaravel-license-core

###  Code Quality

TestsPest

Static AnalysisPHPStan, Rector

Code StyleLaravel Pint

### Embed Badge

![Health badge](/badges/akira-laravel-license-core/health.svg)

```
[![Health](https://phpackages.com/badges/akira-laravel-license-core/health.svg)](https://phpackages.com/packages/akira-laravel-license-core)
```

###  Alternatives

[spatie/laravel-permission

Permission handling for Laravel 12 and up

12.9k89.8M1.0k](/packages/spatie-laravel-permission)[bezhansalleh/filament-shield

Filament support for `spatie/laravel-permission`.

2.8k2.9M88](/packages/bezhansalleh-filament-shield)[jeffgreco13/filament-breezy

A custom package for Filament with login flow, profile and teams support.

1.0k1.7M41](/packages/jeffgreco13-filament-breezy)[spatie/laravel-login-link

Quickly login to your local environment

4381.2M1](/packages/spatie-laravel-login-link)[ryangjchandler/laravel-cloudflare-turnstile

A simple package to help integrate Cloudflare Turnstile.

438896.6k2](/packages/ryangjchandler-laravel-cloudflare-turnstile)[spatie/laravel-passkeys

Use passkeys in your Laravel app

444494.4k16](/packages/spatie-laravel-passkeys)

PHPackages © 2026

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