Skip to content
docsv0.1.0

HandlerReference

An immutable, framework-agnostic pointer to the code a route runs: a controller class plus the method that handles the request (defaulting to `__invoke` for a single-action handler class). Serializable, so route tables can be compiled and cached; a {@see HandlerResolverInterface} turns it into a live PSR-15 request handler.

HandlerReference::__construct()

public function __construct(string $controller, string $method = '__invoke'):

Parameters

Parameters of __construct()
NameTypeDescription
$controllerclass-stringthe handler class
$methodstringthe method that handles the request

HandlerReference::action()

public static function action(string $controller): self

Reference a single-action handler class through its `__invoke` method.

Parameters

Parameters of action()
NameTypeDescription
$controllerclass-string

HandlerReference::method()

public static function method(string $controller, string $method): self

Reference a specific method on a controller class.

Parameters

Parameters of method()
NameTypeDescription
$controllerclass-string
$methodstring

HandlerReference::__toString()

public function __toString(): string

Render the reference as `Controller::method`.