class Registrar

Traits

Constants

OAUTH_SCOPE

Properties

static protected array $macros

The registered string macros.

from  Macroable
protected array<string, callable> $localServers
protected Route> $httpServers

Methods

static void
macro(string $name, callable|object $macro)

Register a custom macro.

static void
mixin(object $mixin, bool $replace = true)

Mix another object into the class.

static bool
hasMacro(string $name)

Check if macro is registered.

static void
flushMacros()

Flush the existing macros.

static mixed
__callStatic(string $method, array $parameters)

Dynamically handle calls to the class.

mixed
__call(string $method, array $parameters)

Dynamically handle calls to the class.

web(string $route, string $serverClass)

Register an HTTP server.

void
local(string $handle, string $serverClass)

Register a local server.

void
registerClient(string $name, Closure $factory)

Register a named client factory.

client(string $name)

Get a named client for the current owner.

void
oAuthRoutesFor(string $client, Closure|array $handler, array|string $middleware = 'web', string|null $connectUri = null, string|null $callbackUri = null, string|null $clientMetadataUri = null, array $clientMetadata = [])

Register OAuth routes for a named client.

callable|null
getLocalServer(string $handle)

Get a local server factory.

Route|null
getWebServer(string $route)

Get a registered HTTP server route.

array
servers()

Get the registered servers.

void
oauthRoutes(string $oauthPrefix = 'oauth', bool $registration = true)

Register server-side OAuth discovery and registration routes.

static array
protectedResourceMetadata(string $path)

Get discovery metadata for a protected resource.

bool
hasGetRoute(string $uri)

Determine whether an exact GET route is already registered.

static array
ensureMcpScope()

Add the MCP scope when Passport is installed.

clientManager()

Get the client manager.

static mixed
startServer(string $serverClass, callable $transportFactory)

Start a server on its transport.

Details

in Macroable at line 30
static void macro(string $name, callable|object $macro)

Register a custom macro.

Macros persist in a static property for the worker lifetime and apply to every subsequent call on the macroable class.

Parameters

string $name
callable|object $macro

Return Value

void

in Macroable at line 44
static void mixin(object $mixin, bool $replace = true)

Mix another object into the class.

Delegates to macro() for each method; registered macros persist in a static property for the worker lifetime.

Parameters

object $mixin
bool $replace

Return Value

void

Exceptions

ReflectionException

in Macroable at line 61
static bool hasMacro(string $name)

Check if macro is registered.

Parameters

string $name

Return Value

bool

in Macroable at line 72
static void flushMacros()

Flush the existing macros.

Clears worker-wide macros; concurrent coroutines may resolve different methods depending on timing.

Return Value

void

in Macroable at line 83
static mixed __callStatic(string $method, array $parameters)

Dynamically handle calls to the class.

Parameters

string $method
array $parameters

Return Value

mixed

Exceptions

BadMethodCallException

in Macroable at line 108
mixed __call(string $method, array $parameters)

Dynamically handle calls to the class.

Parameters

string $method
array $parameters

Return Value

mixed

Exceptions

BadMethodCallException

at line 52
Route web(string $route, string $serverClass)

Register an HTTP server.

Routes and server registrations persist for the worker lifetime.

Parameters

string $route
string $serverClass

Return Value

Route

at line 82
void local(string $handle, string $serverClass)

Register a local server.

On the shared registrar, server factories persist across requests.

Parameters

string $handle
string $serverClass

Return Value

void

at line 95
void registerClient(string $name, Closure $factory)

Register a named client factory.

Client factories persist for the worker lifetime.

Parameters

string $name
Closure $factory

Return Value

void

at line 104
Client client(string $name)

Get a named client for the current owner.

Parameters

string $name

Return Value

Client

at line 118
void oAuthRoutesFor(string $client, Closure|array $handler, array|string $middleware = 'web', string|null $connectUri = null, string|null $callbackUri = null, string|null $clientMetadataUri = null, array $clientMetadata = [])

Register OAuth routes for a named client.

The routes persist for the worker lifetime.

Parameters

string $client
Closure|array $handler

receives provider or client, token, and optional returnTo by parameter name

array|string $middleware
string|null $connectUri
string|null $callbackUri
string|null $clientMetadataUri
array $clientMetadata

Return Value

void

at line 134
callable|null getLocalServer(string $handle)

Get a local server factory.

Parameters

string $handle

Return Value

callable|null

at line 142
Route|null getWebServer(string $route)

Get a registered HTTP server route.

Parameters

string $route

Return Value

Route|null

at line 152
array servers()

Get the registered servers.

Return Value

array

at line 165
void oauthRoutes(string $oauthPrefix = 'oauth', bool $registration = true)

Register server-side OAuth discovery and registration routes.

Routes and Passport's challenge resolver persist for the worker lifetime.

Parameters

string $oauthPrefix
bool $registration

Return Value

void

at line 209
static protected array protectedResourceMetadata(string $path)

Get discovery metadata for a protected resource.

Parameters

string $path

Return Value

array

at line 232
protected bool hasGetRoute(string $uri)

Determine whether an exact GET route is already registered.

Parameters

string $uri

Return Value

bool

at line 256
static array ensureMcpScope()

Add the MCP scope when Passport is installed.

Passport scopes persist for the worker lifetime.

Return Value

array

at line 276
protected ClientManager clientManager()

Get the client manager.

Return Value

ClientManager

at line 287
static protected mixed startServer(string $serverClass, callable $transportFactory)

Start a server on its transport.

Parameters

string $serverClass
callable $transportFactory

Return Value

mixed