承接 getkey/licencephp 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

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

getkey/licencephp

Composer 安装命令:

composer require getkey/licencephp

包简介

getkey is a license management application that can be used by everyone

README 文档

README

Support: Framework Laravel, Ci

Introduction

The GetKey PHP API Client Library allows the integration of various data validation features into your applications. For more information, please visit getkey.my.id.

Requirements

To use the GetKey API client, you need the following:

  • A GetKey account
  • An Application project created with a generated API key

Installation

To begin using the GetKey PHP API Client library, follow these installation steps:

With Composer

  1. Install the library using Composer:

    composer require getkey/licencephp
  2. Include the Composer autoloader in your PHP script:

    require_once 'vendor/autoload.php';

Without Composer

  1. Download the library and add it to your project.

  2. Include the file vendor/autoload.php in your PHP script:

    include_once "getkey-licence-api-client/vendor/autoload.php";

If you experience errors, then try adding this

require_once __DIR__ . '../vendor/getkey/licencephp/src/LicenceManager.php';

Getting Started

To start validating and using the API, create a Traits system in your framework. You need to create a licence first on the getkey.my.id site, then you can use the licence name to call the licence API.

Full Example of License Validation

Create a trait to manage and validate the licence:

trait ManagesLicense
{
    protected $licenceManager;
    protected $pemFilePath;

    // Automatically initialize when the trait is used
    public function __construct()
    {
        $this->initializeLicenseManager();
    }

    // Initialize the LicenseManager instance
    protected function initializeLicenseManager($endpoint = null)
    {
        $endpoint = $endpoint ?: config('services.licence.endpoint');
        $this->licenceManager = new LicenseManager($endpoint);
    }

    // Set the PEM file path based on the script name
    protected function setPemFilePath($scriptName)
    {
        $this->pemFilePath = storage_path('licences/' . $scriptName . '.pem');
    }

    // Get the PEM file path
    protected function getPemFilePath()
    {
        return $this->pemFilePath;
    }

    // Combined method to manage and validate the licence
    public function manageAndValidateLicense($scriptName)
    {
        try {
            if (!$this->licenceManager) {
                $this->initializeLicenseManager();
            }

            // Set the PEM file path using the script name
            $this->setPemFilePath($scriptName);
            $pemFilePath = $this->getPemFilePath();

            // Manage the licence (fetch, save, and validate)
            $this->licenceManager->manageLicense($scriptName, $pemFilePath);

            // Validate the PEM file content
            return $this->licenceManager->verifyPemContent($pemFilePath);
        } catch (Exception $e) {
            return $e->getMessage();
        }
    }
}

Setting Services

Add this setting to the service configuration, for example in config/services.php for Laravel:

'licence' => [
    'endpoint' => env('LICENCE_ENDPOINT', 'https://getkey.my.id/api/v1/getLicence'),
],

Alternatively, you can set it in your .env file:

Example of Validation in Controller

use App\Traits\ManagesLicense;

class YourController extends Controller
{
    use ManagesLicense;

    public function yourMethod()
    {
        $scriptName = "Licence1";

        // Manage and validate the licence
        $result = $this->manageAndValidateLicense($scriptName);

        if ($result === true) {
            // Logic for successful validation
            return view('welcome');
        } else {
            // Logic for failed validation
            return response()->json(['error' => $result], 500);
        }
    }
}

Response Class

The Response class is returned with every request, providing methods to handle responses as detailed in the library documentation.

Testing

getkey is still in beta stage, and you can try it right now. report any bugs in the class licence or api. please note:

for api endpoints it has not been validated with token, only validated by licencename, but with hashing security... then the licence is used by one user, it cannot be used by two users in one project.

getkey/licencephp 适用场景与选型建议

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

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

围绕 getkey/licencephp 我们能提供哪些服务?
定制开发 / 二次开发

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2024-08-30