Menu
Reference
request()
function
function request(): ?Request
The request being served on the current flow, or null outside one.
For code that is too deep to be handed the Request: a logger, a repository, an error page. The
server binds the request in a per-request Async\Context scope, so it is visible in the handler
and in every task the handler spawns, and in nothing else. That keeps it correct with many
requests in flight. Bind your own request-scoped values with Async\Context::withValue().
Returns
?Request — The current request, or null when called outside a request.