PHPackages                             maymeow/license - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. maymeow/license

ActiveLibrary

maymeow/license
===============

License package for PHP apps

0166↓100%[1 issues](https://github.com/MayMeow/license/issues)PHP

Since Jan 14Pushed 2mo ago1 watchersCompare

[ Source](https://github.com/MayMeow/license)[ Packagist](https://packagist.org/packages/maymeow/license)[ RSS](/packages/maymeow-license/feed)WikiDiscussions main Synced today

READMEChangelogDependenciesVersions (2)Used By (0)

License package for PHP applications
====================================

[](#license-package-for-php-applications)

Lightweight helper to issue and validate signed licenses for your PHP apps using elliptic-curve cryptography.

Requirements
------------

[](#requirements)

- PHP 8.1+ with the OpenSSL extension enabled

Installation
------------

[](#installation)

If published to Packagist:

```
composer require maymeow/license
```

For local development in this repo:

```
composer install
```

Quick start
-----------

[](#quick-start)

Generate a key pair for your license issuer and application, sign a license, and validate it.

```
use MayMeow\License\ECCryptographyHelper;
use MayMeow\License\License;
use MayMeow\License\LicenseGenerator;
use MayMeow\License\UnsignedArrayHelper;

require __DIR__ . '/vendor/autoload.php';

$crypto = new ECCryptographyHelper();

// 1) Create EC key pairs
[$issuerPrivateKey, $issuerPublicKey] = $crypto->generateEcKeyPair();

// 2) Build license payload
$licensePayload = LicenseGenerator::generateLicense(
	name: 'Alice Smith',
	email: 'alice@example.com',
	applicationFeatures: ['blogs' => 5],
	validDays: 365
);

// 3) Sign license with issuer private key
$signedLicense = LicenseGenerator::signLicense($licensePayload, $issuerPrivateKey);

// 4) Validate in your app using issuer public key
$appPublicKeyBytes = UnsignedArrayHelper::convertKeyToUnsignedArray($issuerPublicKey);
$license = new License($appPublicKeyBytes, $signedLicense);

if ($license->isValid()) {
	// gate features
	if ($license->hasFeature('blogs')) {
		// allow feature
	}
}
```

API highlights
--------------

[](#api-highlights)

- `LicenseGenerator::generateLicense()` builds license metadata (id, owner, email, features, expiry).
- `LicenseGenerator::signLicense()` signs the license JSON with an EC private key and returns a compact base64 package.
- `LicenseGenerator::verifyLicense()` verifies a signed package with an EC public key.
- `License` instance wraps a signed package and exposes:
    - `isValid()` signature + expiry check
    - `isExpired()` expiry only
    - `hasFeature($key)` convenience feature flag lookup
    - `getOriginalLiceseData()` returns the original base64 payload
    - `getFeatureValue($key)` returns feature value when it is sed or true/false when the feature is only a key.

### Handling keys as unsigned byte arrays

[](#handling-keys-as-unsigned-byte-arrays)

If you store keys as unsigned byte arrays (e.g., in config), convert them with `UnsignedArrayHelper`:

```
// Convert PEM to array
$publicKeyBytes = UnsignedArrayHelper::convertKeyToUnsignedArray($issuerPublicKey);

// Convert array back to PEM
$publicKeyPem = UnsignedArrayHelper::convertUnsignedArrayToKey($publicKeyBytes, 'public');
```

Additional helpers
------------------

[](#additional-helpers)

- `ECCryptographyHelper` also supports shared-secret derivation (`deriveSharedSecret`), HKDF, and AES-256-GCM encrypt/decrypt for custom payload handling.
- `RSACryptographyHelper` offers basic RSA key generation and private/public encrypt/decrypt helpers if you prefer RSA.

Running the examples
--------------------

[](#running-the-examples)

- `php test.php` generates a license, signs it, and validates it end-to-end.
- `php verificationtest.php` demonstrates verifying a prebuilt license package.

License
-------

[](#license)

MIT

###  Health Score

23

—

LowBetter than 30% of packages

Maintenance57

Moderate activity, may be stable

Popularity13

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity13

Early-stage or recently created project

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

### Community

Maintainers

![](https://www.gravatar.com/avatar/f7c2bca298b9947b96e7d8ecc3e58d2a63caf97adb52d28c07dc8b9468cdabb6?d=identicon)[maymeow](/maintainers/maymeow)

---

Top Contributors

[![MayMeow](https://avatars.githubusercontent.com/u/3164256?v=4)](https://github.com/MayMeow "MayMeow (15 commits)")

### Embed Badge

![Health badge](/badges/maymeow-license/health.svg)

```
[![Health](https://phpackages.com/badges/maymeow-license/health.svg)](https://phpackages.com/packages/maymeow-license)
```

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
