-
Notifications
You must be signed in to change notification settings - Fork 0
Context
The Context
class provides an easy DSL-like interface for accessing response and request objects. The setter methods are used for preparing a response to be sent to the client while most getters retrieve data from the request - including route params and wildcards. Additionally, context objects can validate different part of incoming data - body, forms and parameters.
WIP
WIP
WIP
WIP
WIP
WIP
WIP
WIP
halt(int $status = Status::OK, InputStream|string|null $stringOrStream = null, array $headers = []): void
WIP
WIP
WIP
WIP
WIP
WIP
WIP
WIP
WIP
WIP
Generates a redirect response. This function is different from halt
in that doesn't stop processing the current handler coroutine.
$ctx->redirect('/foo', Status::FOUND);
$logger->info('This will be logged');
$ctx->halt(Status::NOT FOUND);
$logger->info('This will not be logged');
Removes a cookie from the response.
Removes a header from the response.
Gets the request body. The request body can be buffer
ed.
Gets a request header.
Sets the response body to the specified string or stream. Read more about streams here.
Gets the response body. Useful when you need to append/modify the body inside filters or status/exception mappers. Note: in the future a BodyBuilder
class might be introduced.
Sets a response cookie.
Returns the session object associated with this request.
Sets the response status and reason.
WIP
Returns the user-agent string if it was set or null otherwise.
Note: in the future the signature will look like:
validatedBody(string $validatorName): Promise<WrappedValue>`
WIP
Note: in the future the signature will look like:
validatedForm(): Promise<WrappedForm>`
WIP
WIP