PHP Class Zend\Diactoros\ServerRequest

Extends the Request definition to add methods for accessing incoming data, specifically server parameters, cookies, matched path parameters, query string arguments, body parameters, and upload file information. "Attributes" are discovered via decomposing the request (and usually specifically the URI path), and typically will be injected by the application. Requests are considered immutable; all methods that might change state are implemented such that they retain the internal state of the current message and return a new instance that contains the changed state.
Inheritance: implements Psr\Http\Message\ServerRequestInterface, use trait MessageTrait, use trait RequestTrait
Afficher le fichier Open project: zendframework/zend-diactoros Class Usage Examples

Méthodes publiques

Méthode Description
__construct ( array $serverParams = [], array $uploadedFiles = [], null | string | Psr\Http\Message\UriInterface $uri = null, null | string $method = null, string | resource | Psr\Http\Message\StreamInterface $body = 'php://input', array $headers = [], array $cookies = [], array $queryParams = [], null | array | object $parsedBody = null, string $protocol = '1.1' )
getAttribute ( $attribute, $default = null )
getAttributes ( )
getCookieParams ( )
getMethod ( ) : string Proxy to receive the request method.
getParsedBody ( )
getQueryParams ( )
getServerParams ( )
getUploadedFiles ( )
withAttribute ( $attribute, $value )
withCookieParams ( array $cookies )
withMethod ( string $method ) : self Set the request method.
withParsedBody ( $data )
withQueryParams ( array $query )
withUploadedFiles ( array $uploadedFiles )
withoutAttribute ( $attribute )

Private Methods

Méthode Description
validateUploadedFiles ( array $uploadedFiles ) Recursively validate the structure in an uploaded files array.

Method Details

__construct() public méthode

public __construct ( array $serverParams = [], array $uploadedFiles = [], null | string | Psr\Http\Message\UriInterface $uri = null, null | string $method = null, string | resource | Psr\Http\Message\StreamInterface $body = 'php://input', array $headers = [], array $cookies = [], array $queryParams = [], null | array | object $parsedBody = null, string $protocol = '1.1' )
$serverParams array Server parameters, typically from $_SERVER
$uploadedFiles array Upload file information, a tree of UploadedFiles
$uri null | string | Psr\Http\Message\UriInterface URI for the request, if any.
$method null | string HTTP method for the request, if any.
$body string | resource | Psr\Http\Message\StreamInterface Message body, if any.
$headers array Headers for the message, if any.
$cookies array Cookies for the message, if any.
$queryParams array Query params for the message, if any.
$parsedBody null | array | object The deserialized body parameters, if any.
$protocol string HTTP protocol version.

getAttribute() public méthode

public getAttribute ( $attribute, $default = null )

getAttributes() public méthode

public getAttributes ( )

getCookieParams() public méthode

public getCookieParams ( )

getMethod() public méthode

This overrides the parent functionality to ensure the method is never empty; if no method is present, it returns 'GET'.
public getMethod ( ) : string
Résultat string

getParsedBody() public méthode

public getParsedBody ( )

getQueryParams() public méthode

public getQueryParams ( )

getServerParams() public méthode

public getServerParams ( )

getUploadedFiles() public méthode

public getUploadedFiles ( )

withAttribute() public méthode

public withAttribute ( $attribute, $value )

withCookieParams() public méthode

public withCookieParams ( array $cookies )
$cookies array

withMethod() public méthode

Unlike the regular Request implementation, the server-side normalizes the method to uppercase to ensure consistency and make checking the method simpler. This methods returns a new instance.
public withMethod ( string $method ) : self
$method string
Résultat self

withParsedBody() public méthode

public withParsedBody ( $data )

withQueryParams() public méthode

public withQueryParams ( array $query )
$query array

withUploadedFiles() public méthode

public withUploadedFiles ( array $uploadedFiles )
$uploadedFiles array

withoutAttribute() public méthode

public withoutAttribute ( $attribute )