PHPackages                             hasemon/laravel-license-gate - 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. hasemon/laravel-license-gate

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

hasemon/laravel-license-gate
============================

Laravel package for enforcing application license validation with configurable storage.

00PHP

Since Feb 19Pushed 2mo agoCompare

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

READMEChangelogDependenciesVersions (1)Used By (0)

Laravel License Gate
====================

[](#laravel-license-gate)

`hasemon/laravel-license-gate` is a Laravel 12 package to validate and enforce license access through middleware.

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

[](#requirements)

- PHP 8.2+
- Laravel 12
- A table to store license values (default: `settings`)

Default storage columns:

- `license_key` (string)
- `license_expires_at` (timestamp nullable)
- `id` (used for updates)
- `created_at` and `updated_at` (written by the default repository)

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

[](#installation)

```
composer require hasemon/laravel-license-gate
```

The service provider is auto-discovered.

Publish config:

```
php artisan vendor:publish --tag=license-gate-config
```

Configuration
-------------

[](#configuration)

Create or update your env values:

```
LICENSE_SECRET=hasemon
```

The default config file is `config/license-gate.php`:

- `secret`: encryption/decryption secret for license keys
- `cipher`: default `aes-256-cbc`
- `iv_length`: default `16`
- `storage.*`: table and column mapping
- `redirect_route`: web redirect route when license is invalid
- `json_error_message`: message for JSON 403 responses

Usage
-----

[](#usage)

### 1. Register middleware alias

[](#1-register-middleware-alias)

In Laravel 12, add alias in `bootstrap/app.php`:

```
use Hasemon\LaravelLicenseGate\Middleware\CheckLicense;

->withMiddleware(function (Middleware $middleware): void {
    $middleware->alias([
        'license' => CheckLicense::class,
    ]);
})
```

### 2. Protect routes

[](#2-protect-routes)

```
Route::middleware(['auth', 'verified', 'license'])->group(function () {
    Route::get('/dashboard', fn () => Inertia::render('dashboard'))->name('dashboard');
});
```

Behavior:

- Unauthenticated requests pass through middleware
- Authenticated + valid license passes through
- Authenticated + invalid/expired license:
    - Web: redirects to `route(config('license-gate.redirect_route'))`
    - JSON: returns `403` with `json_error_message`

### 3. Store a submitted license key

[](#3-store-a-submitted-license-key)

Use `StoreLicenseAction` in your controller:

```
use Hasemon\LaravelLicenseGate\Actions\StoreLicenseAction;

public function storeLicense(Request $request, StoreLicenseAction $storeLicenseAction): RedirectResponse
{
    $request->validate([
        'license_key' => ['required', 'string', 'max:500'],
    ]);

    $storeLicenseAction($request->string('license_key')->toString());

    return redirect()->route('dashboard');
}
```

### 4. Validate license manually (optional)

[](#4-validate-license-manually-optional)

```
use Hasemon\LaravelLicenseGate\Actions\ValidateLicenseAction;

$isValid = app(ValidateLicenseAction::class)();
```

Using with external key generator
---------------------------------

[](#using-with-external-key-generator)

If you generate keys outside the app, make sure it uses the same:

- `LICENSE_SECRET`
- cipher (`aes-256-cbc`)
- key format (`base64(iv + ciphertext)`)

Standalone license portal URL
-----------------------------

[](#standalone-license-portal-url)

If your team uses a standalone licensing app (where users log in and generate keys), expose that URL in your main app and show it on the license-expired page.

Example env:

```
LICENSE_PORTAL_URL=https://license.example.com/login
```

Pass it to your Inertia page:

```
Route::get('license-expired', function () {
    return Inertia::render('auth/license-expired', [
        'licenseStoreUrl' => route('license.store'),
        'licensePortalUrl' => config('services.license.portal_url'),
    ]);
})->name('license.expired');
```

`config/services.php`:

```
'license' => [
    'portal_url' => env('LICENSE_PORTAL_URL'),
],
```

In your `license-expired` UI, render a link/button to that portal:

```

    Get license key

```

Recommended user flow:

- User opens license portal URL
- User logs in to standalone licensing app
- User generates/copies license key
- User returns to your app and submits key

Custom storage mapping
----------------------

[](#custom-storage-mapping)

If your table/columns differ, change `config/license-gate.php`:

```
'storage' => [
    'table' => 'settings',
    'license_key_column' => 'license_key',
    'license_expires_at_column' => 'license_expires_at',
],
```

Notes
-----

[](#notes)

- `license_expires_at` in storage is for convenience.
- Validation trusts decrypted `license_key` payload, not stored expiry value.

###  Health Score

19

—

LowBetter than 10% of packages

Maintenance56

Moderate activity, may be stable

Popularity0

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity12

Early-stage or recently created project

 Bus Factor1

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

### Community

Maintainers

![](https://www.gravatar.com/avatar/668d237e08f11f1a7e98fdc9b040caf6459c021424300268ca9a39eee3556c13?d=identicon)[hasemon](/maintainers/hasemon)

---

Top Contributors

[![hasemon](https://avatars.githubusercontent.com/u/129359809?v=4)](https://github.com/hasemon "hasemon (1 commits)")

### Embed Badge

![Health badge](/badges/hasemon-laravel-license-gate/health.svg)

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

###  Alternatives

[bezhansalleh/filament-shield

Filament support for `spatie/laravel-permission`.

2.8k2.9M88](/packages/bezhansalleh-filament-shield)[gesdinet/jwt-refresh-token-bundle

Implements a refresh token system over Json Web Tokens in Symfony

70516.4M35](/packages/gesdinet-jwt-refresh-token-bundle)[illuminate/auth

The Illuminate Auth package.

9327.3M1.0k](/packages/illuminate-auth)[beatswitch/lock

A flexible, driver based Acl package for PHP 5.4+

870304.7k2](/packages/beatswitch-lock)[amocrm/amocrm-api-library

amoCRM API Client

182728.5k6](/packages/amocrm-amocrm-api-library)[vonage/jwt

A standalone package for creating JWTs for Vonage APIs

424.1M4](/packages/vonage-jwt)

PHPackages © 2026

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