Services

LicenseServiceInterface

v1.0.0

License activation and status inspection for modules that depend on licensed features.

Access

$ctx->license()?->isActive();

How To Use It

  • Use it to gate paid features, activation flows, and support diagnostics against the runtime license state.
  • Treat the returned LicenseStatus as the source of truth for plan, expiry, and feature flags instead of duplicating that state in settings.

Works Well With

Methods

public function getStatus(): LicenseStatus

Returns the current license status DTO.

public function activate(string $key): LicenseStatus

Activates a license key and returns the resulting status.

public function deactivate(): bool

Deactivates the current license and reports whether the operation succeeded.

public function isActive(): bool

Convenience check that reports whether the current license is active.

Example

bootstrap.php
public function activateLicense(SdkContext $ctx, string $key): void
{
    $status = $ctx->license()?->activate($key);

    $ctx->logger()->info('reports.license_updated', [
        'status' => $status?->status,
        'active' => $status?->isActive(),
    ]);
}