Skip to content

RequestAttribute ​

Solo\Application\RequestAttribute names the request attributes that RoutingMiddleware writes and RouteDispatcher reads.

php
final class RequestAttribute
ConstantValueTypeDescription
HANDLER'handler'array{class-string,string} | string | callableMatched handler: [class, method], a container ID or a callable
PARAMS'params'array<string, string>Route parameters, percent-decoded
ROUTE_NAME'route_name'string | nullRoute name, or null for an unnamed route
ROUTE_ATTRIBUTES'route_attributes'array<string, mixed>Custom route attributes
php
use Solo\Application\RequestAttribute;

$name = $request->getAttribute(RequestAttribute::ROUTE_NAME);
$permission = $request->getAttribute(RequestAttribute::ROUTE_ATTRIBUTES, [])['permission'] ?? null;

A custom routing middleware sets HANDLER and PARAMS for the dispatcher.

Released under the MIT License.