定制 jmrashed/purchase-key-guard 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

jmrashed/purchase-key-guard

Composer 安装命令:

composer require jmrashed/purchase-key-guard

包简介

A Laravel package to protect usage via a purchase key.

README 文档

README

Latest Version on Packagist Latest Version 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.
  • Duplicate purchase code prevention.
  • Configurable API URL for external revalidation.
  • Comprehensive unit tests.

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

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

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

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

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

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

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

purchase-key:check-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

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

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

To run the package tests, simply execute:

composer test

License

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

Author

Md Rasheduzzaman
Full-Stack Software Engineer & Technical Project Manager

Building scalable, secure & 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
✉️ Email: jmrashed@gmail.com
💼 LinkedIn: linkedin.com/in/jmrashed
📝 Blog: medium.com/@jmrashed
💻 GitHub: github.com/jmrashed

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

jmrashed/purchase-key-guard 适用场景与选型建议

jmrashed/purchase-key-guard 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 24 次下载、GitHub Stars 达 4, 最近一次更新时间为 2024 年 10 月 14 日, 在 PHP 生态内属于活跃度较高的组件。

我们在过去多个企业项目中使用过 jmrashed/purchase-key-guard 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 jmrashed/purchase-key-guard 我们能提供哪些服务?
定制开发 / 二次开发

基于 jmrashed/purchase-key-guard 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 24
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 4
  • 点击次数: 15
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 4
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2024-10-14