ControllerResolver
final class ControllerResolver (View source)
Route-to-controller dispatcher for HTTP requests.
The resolver obtains controller instances through the dependency injection container, resolves the current scoped PSR-7 server request for the dispatch cycle, resolves action parameters from the request and route parameters, performs scalar conversion for builtin parameter types, invokes the controller action, and normalizes the result to a PSR-7 response.
Methods
Accepts the scoped container used for controller resolution and optional diagnostics.
Dispatches the matched controller action and normalizes its result to a PSR-7 response.
Details
__construct
__construct(ContainerInterface $container, HttpInstrumentation|null $diagnostics = null)
Accepts the scoped container used for controller resolution and optional diagnostics.
handle
ResponseInterface
handle(RouteMatch $match, ServerRequestInterface $request)
Dispatches the matched controller action and normalizes its result to a PSR-7 response.
The current request is already bound into the active scope by the kernel.
The resolver then reads the controller class, action, and route
parameters from the route match, resolves the controller through the
container, injects ServerRequestInterface action parameters directly, maps named
route parameters to action arguments, converts builtin int, float,
bool, and string parameters, applies declared default values when
route parameters are absent, invokes the action, and normalizes the
result.
Existing PSR responses are returned unchanged. Scalar, stringable, and
null results are converted to a 200 text/html; charset=UTF-8
response.