Download the PHP package code-heaven/license-sdk without Composer
On this page you can find all versions of the php package code-heaven/license-sdk. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download code-heaven/license-sdk
More information about code-heaven/license-sdk
Files in code-heaven/license-sdk
Package license-sdk
Short Description Vendor SDK for the Code Heaven Developer License API (validation, domain activation, updates, downloads).
License MIT
Informations about the package license-sdk
Code Heaven License SDK (PHP)
Vendor SDK for the Code Heaven Developer License API. Use it inside your plugin/theme/app to validate licenses, activate and free domain seats, check for updates, and fetch signed download URLs.
This is the vendor server-to-server flow. Authentication is a single vendor
API key (X-CH-Vendor-Key), not the buyer OAuth flow.
- Base URL:
https://api.code-heaven.com/v1 - PHP 8.0+
- No hard runtime dependencies (cURL or
file_get_contents); pluggable HTTP so it works happily inside WordPress viawp_remote_request.
Install
Quick start: validate and gate
validate() returns the decoded API body plus two SDK markers:
| key | meaning |
|---|---|
valid |
bool |
status |
valid | invalid | expired | domain_not_activated | revoked |
product |
product slug (or null) |
expiresAt |
ISO 8601 string or null |
activations |
[{domain, activatedAt}, ...] |
seatLimit |
int |
_cached |
present & true when served from cache |
_offline |
present & true when served from cache during an outage |
Activate a seat on first run
When validate() returns domain_not_activated (a LicenseException with
apiCode === 'domain_not_activated'), claim a seat:
Check for and apply an update
Free the seat on uninstall
Caching and offline grace
validate() is cached so repeated calls in one request never hit the wire
twice, and the result persists across requests when you supply a persistent
cache:
cacheTtl— how long a cached answer is considered fresh. Within this windowvalidate()returns the cached body without any network call.offlineGrace— how long a cachedvalidanswer may be served after it goes stale, but only when the API is unreachable. This stops a transient outage from locking out paying customers. Served results carry_offline => true.
Persistent caches:
The default is an in-process ArrayCache (no cross-request persistence, so no
offline grace across requests — supply FileCache/TransientCache in
production).
Custom HTTP transport (WordPress, Guzzle, …)
Inject any callable as http. It receives (method, url, headers, ?body) and
must return ['status' => int, 'headers' => array, 'body' => string], or throw
TransportException on a connection failure (which triggers offline grace).
See examples/gate-plugin.php for a complete,
fail-safe WordPress gate (validate → activate-on-first-run → admin nag →
deactivate-on-uninstall).
Exceptions
All extend CodeHeaven\License\CodeHeavenException and expose
->statusCode, ->apiCode, ->response.
| Exception | HTTP | When |
|---|---|---|
AuthException |
401 | Vendor key missing/invalid (your packaging bug) |
LicenseException |
403 | license_invalid / expired / domain_not_activated |
SeatLimitException |
409 | seat_limit_exceeded on activateDomain() |
RateLimitException |
429 | Rate limited (->retryAfter holds the hint, if any) |
TransportException |
— | API unreachable and no usable cached result |
CodeHeavenException |
4xx/5xx | Any other non-2xx response |
Note: an invalid or expired license that the API reports with HTTP 200 and
valid:falseis returned as data, not thrown. The API only throwsLicenseExceptionfor the 403 cases above.
Development
License
MIT.