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
-
Install the library using Composer:
composer require getkey/licencephp
-
Include the Composer autoloader in your PHP script:
require_once 'vendor/autoload.php';
Without Composer
-
Download the library and add it to your project.
-
Include the file
vendor/autoload.phpin 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:
- LICENCE_ENDPOINT=https://getkey.my.id/api/v1/getLicence
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 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 4
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 14
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2024-08-30