📜  license_verify - PHP (1)

📅  最后修改于: 2023-12-03 15:32:38.970000             🧑  作者: Mango

License Verify - PHP

License Verify is a PHP library that helps verify licenses for PHP applications. This library can be used for web applications or desktop applications written in PHP. It provides easy integration with your existing code and prevents unauthorized usage of your application.

Features
  • Securely verifies licenses using a secret key and license data.
  • Supports multiple license formats, including JSON and XML.
  • Easy integration with your existing codebase.
  • Portable and lightweight, compatible with most PHP environments.
  • Supports custom validation rules for license data.
Installation

You can install License Verify using Composer:

composer require your-username/license-verify
Usage

To use License Verify, you need to first create a license file for your application. This file should contain information about the license, including the expiration date, the maximum number of users, and any custom data you want to include.

Once you have the license file, you can use License Verify to verify the license in your PHP code. Here is an example:

use LicenseVerify\License;

$licenseData = file_get_contents('/path/to/license.json');

$license = new License($licenseData, 'your-secret-key');

if ($license->isValid()) {
    // License is valid, continue with application logic
} else {
    // License is not valid, handle the error
}
Custom Validation Rules

If your license data contains custom data that you want to validate, you can define custom validation rules. Here is an example:

use LicenseVerify\License;
use LicenseVerify\ValidationRule;

$licenseData = file_get_contents('/path/to/license.json');

$license = new License($licenseData, 'your-secret-key');
$license->addValidationRule(new ValidationRule('customData', function($customData) {
    if ($customData == 'foo') {
        return true;
    }

    return false;
}));

if ($license->isValid()) {
    // License is valid, continue with application logic
} else {
    // License is not valid, handle the error
}
Conclusion

License Verify is a powerful and flexible library that makes it easy to verify licenses for your PHP applications. With support for multiple license formats and custom validation rules, you can ensure that your application is only being used by authorized users.