KMP PHP API Reference

TenantContext
in package

FinalYes

Tracks the active tenant for the current request, worker message, or CLI scope.

Table of Contents

Properties

$stack  : array<int, TenantMetadata>

Methods

current()  : TenantMetadata
Return the active tenant or fail fast if code is not tenant-scoped.
id()  : string
Return the active tenant id.
slug()  : string
Return the active tenant slug.
tryCurrent()  : TenantMetadata|null
Return the active tenant when one is set.
with()  : TReturn
Run a callback with the supplied tenant context and always restore the previous context.
__construct()  : mixed
Static utility class.

Properties

Methods

id()

Return the active tenant id.

public static id() : string
Return values
string

slug()

Return the active tenant slug.

public static slug() : string
Return values
string

with()

Run a callback with the supplied tenant context and always restore the previous context.

public static with(TenantMetadata $tenant, callable(): TReturn $callback) : TReturn
Parameters
$tenant : TenantMetadata

Tenant metadata

$callback : callable(): TReturn

Callback to run

Tags
template
Return values
TReturn

__construct()

Static utility class.

private __construct() : mixed
On this page

Search results