Response
The request library is already loaded in provider (also called container).
You can access the request in your controller methods either through the second parameter or by injecting the RequestInterface into the constructor via dependency injection.
Method list
Query Parameters
The getQueryParams method retrieves deserialized query string arguments from the incoming request. These query parameters are typically part of the request's URI ($_GET) and can be used to convey additional information to the server.
withQueryParams: Returns an instance with specified query string arguments.
Parsed Body
The Parsed Body deals with retrieving and manipulating the content of the request body, which can contain data sent by the client, such as form submissions or JSON payloads. The associated method bellow retrieves deserialized body parameters from the request. If the request Content-Type is either application/x-www-form-urlencoded or multipart/form-datathen this method returns the contents of $_POST, while Content-Type is application/json or application/xml then JSON or XML payload is expected.
withParsedBody: Returns an instance with specified body parameters.
Server Parameters
Retrieves server parameters from the incoming request environment.
Cookies
Retrieves cookies sent by the client to the server.
withCookieParams: Returns an instance with specified cookies.
Uploaded Files
Retrieves normalized file upload data.
withUploadedFiles: Returns an instance with specified uploaded files.
Attributes
Retrieves attributes derived from the request or Retrieves a single derived request attribute.
withAttribute: Returns an instance with specified derived request attribute. withoutAttribute: Returns an instance that removes the specified derived request attribute.
Request class
Request Target
Get the message request target (path+query)
withRequestTarget: Return an instance with the specific set requestTarget
Request Method
Get the message request method (always as upper case)
withMethod: Return an instance with the specific set Method
Request URI
Get URI instance with set request message
withUri: Return an instance with the with a new instance of UriInterface set
Is SSL?
Check if is request is SSL
Server request port
Get Server request port
Methods for Immutability
The following methods ensure immutability:
withCookieParams
withQueryParams
withUploadedFiles
withParsedBody
withAttribute
withoutAttribute
withRequestTarget
withMethod
withUri
These methods create and return a new instance with the updated values, preserving the immutability of the original ServerRequest
object.
Last updated