jmrashed/purchase-key-guard

A Laravel package to protect usage via a purchase key.

1.0.18 2024-10-14 10:44 UTC

This package is auto-updated.

Last update: 2024-12-18 08:10:03 UTC


README

Latest Version on Packagist Total Downloads

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

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

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

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

You can modify the configuration by editing the purchase_key.php file. Here, you can set the default key, API settings, and more.

return [
    'key' => env('PURCHASE_KEY', 'your-purchase-key-here'),
];

Testing

To run the package tests, simply execute:

composer test

License

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