PHPackages                             jmrashed/purchase-key-guard - 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. jmrashed/purchase-key-guard

ActiveLibrary

jmrashed/purchase-key-guard
===========================

A Laravel package to protect usage via a purchase key.

1.1.1(1mo ago)424MITPHPPHP ^8.0

Since Oct 14Pushed 1mo ago1 watchersCompare

[ Source](https://github.com/jmrashed/purchase-key-guard)[ Packagist](https://packagist.org/packages/jmrashed/purchase-key-guard)[ RSS](/packages/jmrashed-purchase-key-guard/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependencies (8)Versions (20)Used By (0)

Purchase Key Guard
==================

[](#purchase-key-guard)

[![Latest Version on Packagist](https://camo.githubusercontent.com/a321c6faa7fcee51d38e881c4515f04aaa405f1894c2b65496541c652f9c09e2/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6a6d7261736865642f70757263686173652d6b65792d67756172642e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/jmrashed/purchase-key-guard)[![Latest Version](https://camo.githubusercontent.com/5c3bb753dae1c3c524fcfcc23125b6da78fb2cfeb7820386d9250a0a74b83865/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f762f7461672f6a6d7261736865642f70757263686173652d6b65792d67756172642e7376673f7374796c653d666c61742d737175617265)](https://github.com/jmrashed/purchase-key-guard/tags)[![Total Downloads](https://camo.githubusercontent.com/d69a55a6df71b24a15024728a9eca703b765ed623c11fee797a85ae3a5db489d/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6a6d7261736865642f70757263686173652d6b65792d67756172642e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/jmrashed/purchase-key-guard)

Introduction
------------

[](#introduction)

**Purchase Key Guard** is a Laravel package that helps protect your Laravel application from unauthorized use by validating a purchase key. It uses middleware to ensure that the application can only be used with a valid purchase key, making it a great solution for commercial or licensed applications.

Features
--------

[](#features)

- Middleware to validate purchase keys.
- API support for key validation.
- Easy-to-configure purchase key service.
- Customizable via configuration file.
- Integration with Laravel service providers and facades.
- Includes artisan commands for key management.
- Duplicate purchase code prevention.
- Configurable API URL for external revalidation.
- Comprehensive unit tests.

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

[](#installation)

You can install the package via Composer:

```
composer require jmrashed/purchase-key-guard
```

Once installed, publish the configuration file using the following command:

```
php artisan vendor:publish --provider="Jmrashed\PurchaseKeyGuard\Providers\PurchaseKeyGuardServiceProvider" --tag="config"
```

This will create a `purchase_key.php` configuration file in your `config/` directory.

Usage
-----

[](#usage)

After installation, the package adds middleware to validate the purchase key. Add the middleware to your `app/Http/Kernel.php`:

```
protected $middlewareGroups = [
    'web' => [
        // other middleware
        \Jmrashed\PurchaseKeyGuard\Http\Middleware\VerifyPurchaseKey::class,
    ],
];
```

You can also use the provided `PurchaseKeyService` to programmatically verify purchase keys.

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

[](#configuration)

After publishing the configuration file, you can find it at `config/purchase-key-guard.php`. This file allows you to configure the settings for the purchase key validation.

### Authentication

[](#authentication)

The `authentication` array allows you to configure multiple vendor accounts for Envato API validation. You can add as many accounts as you need.

```
'authentication' => [

    [

        'vendor' => env('PURCHASE_KEY_VENDOR_ACCOUNT1', 'Account 1'),

        'token' => env('PURCHASE_KEY_TOKEN_ACCOUNT1', ''),

        'item_id' => env('PURCHASE_KEY_ITEM_ID_ACCOUNT1', ''),

        'status' => env('PURCHASE_KEY_STATUS_ACCOUNT1', false),

    ],

    // ...

],
```

- `vendor`: A friendly name for the vendor account.
- `token`: Your Envato API personal token.
- `item_id`: The ID of the item on Envato Market.
- `status`: Whether this vendor account is active or not.

### API URL

[](#api-url)

The `api_url` setting defines the base URL for external code revalidation endpoints used by `PurchaseKeyService`.

```
'api_url' => env('PURCHASE_KEY_GUARD_API_URL', 'https://api.your-service.com'),
```

### Activation Limit

[](#activation-limit)

The `activation_limit` setting determines how many times a purchase key can be activated on different domains.

```
'activation_limit' => env('PURCHASE_KEY_ACTIVATION_LIMIT', 1),
```

Admin Interface
---------------

[](#admin-interface)

The package includes a simple admin interface to manage purchase keys. You can access it at `/admin/purchase-keys`.

The admin interface allows you to:

- View all purchase keys.
- Create new purchase keys.
- Edit existing purchase keys.
- Delete purchase keys.
- Revoke purchase keys.

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

[](#artisan-commands)

The package includes an Artisan command to check for expired keys.

### `purchase-key:check-expired`

[](#purchase-keycheck-expired)

This command will check for purchase keys that have expired and update their status to `expired`.

You can run it manually:

```
php artisan purchase-key:check-expired
```

Or schedule it to run periodically in your `app/Console/Kernel.php` file:

```
protected function schedule(Schedule $schedule)

{

    $schedule->command('purchase-key:check-expired')->daily();

}
```

Events
------

[](#events)

The package fires an event when a purchase key is validated: `purchase.key.validated`.

You can listen for this event in your `EventServiceProvider`:

```
protected $listen = [

    'purchase.key.validated' => [

        // Your listeners here

    ],

];
```

Extending the Package
---------------------

[](#extending-the-package)

You can extend the package by:

- Creating your own views and publishing them.
- Creating your own validation logic by extending the `PurchaseKeyService`.
- Creating your own controllers and routes to customize the behavior of the package.

Testing
-------

[](#testing)

To run the package tests, simply execute:

```
composer test
```

License
-------

[](#license)

The MIT License (MIT). Please see the [LICENSE](LICENSE) file for more details.

Author
------

[](#author)

**Md Rasheduzzaman**
Full-Stack Software Engineer &amp; Technical Project Manager

Building scalable, secure &amp; AI-powered SaaS platforms across ERP, HRMS, CRM, LMS, and E-commerce domains.
Over 10 years of experience leading full-stack teams, cloud infrastructure, and enterprise-grade software delivery.

**🌐 Portfolio:** [jmrashed.github.io](https://jmrashed.github.io/)
**✉️ Email:**
**💼 LinkedIn:** [linkedin.com/in/jmrashed](https://www.linkedin.com/in/jmrashed/)
**📝 Blog:** [medium.com/@jmrashed](https://medium.com/@jmrashed)
**💻 GitHub:** [github.com/jmrashed](https://github.com/jmrashed)

---

> *“Need a Reliable Software Partner? I build scalable, secure &amp; modern solutions for startups and enterprises.”*

###  Health Score

43

—

FairBetter than 91% of packages

Maintenance91

Actively maintained with recent releases

Popularity11

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity53

Maturing project, gaining track record

 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.

###  Release Activity

Cadence

Every ~30 days

Recently: every ~134 days

Total

19

Last Release

44d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/12aeaba318c81d8e123faa3b8961a4e8a1ebf876e2a73b1e1ad08b3e5fc2f901?d=identicon)[jmrashed](/maintainers/jmrashed)

---

Top Contributors

[![jmrashed](https://avatars.githubusercontent.com/u/8583051?v=4)](https://github.com/jmrashed "jmrashed (30 commits)")

---

Tags

codecanyonenvatolaravellicensepackagepurchase

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/jmrashed-purchase-key-guard/health.svg)

```
[![Health](https://phpackages.com/badges/jmrashed-purchase-key-guard/health.svg)](https://phpackages.com/packages/jmrashed-purchase-key-guard)
```

###  Alternatives

[neuron-core/neuron-ai

The PHP Agentic Framework.

1.8k245.3k21](/packages/neuron-core-neuron-ai)[tencentcloud/tencentcloud-sdk-php

TencentCloudApi php sdk

3731.2M42](/packages/tencentcloud-tencentcloud-sdk-php)[aedart/athenaeum

Athenaeum is a mono repository; a collection of various PHP packages

245.2k](/packages/aedart-athenaeum)

PHPackages © 2026

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