ServerRequestCreator
API reference › PSR bridge › creator › ServerRequestCreator
Creates PSR-7 server requests from PHP globals.
Methods
Section titled “Methods”| Method | Description | Defined by |
|---|---|---|
__construct() | Creates a new instance of the ServerRequestCreator class. | ServerRequestCreator |
createFromGlobals() | Builds a PSR request from the current SAPI globals and attaches a php://input body when available. | ServerRequestCreator |
Method details
Section titled “Method details”__construct()
Section titled “__construct() ”public function __construct(Psr\Http\Message\ServerRequestFactoryInterface $serverRequestFactory, Psr\Http\Message\StreamFactoryInterface $streamFactory, Psr\Http\Message\UploadedFileFactoryInterface $uploadedFileFactory)Creates a new instance of the ServerRequestCreator class.
Parameters
| Parameter | Type | Description |
|---|---|---|
$serverRequestFactory | Psr\ | Factory to create server requests. |
$streamFactory | Psr\ | Factory to create streams. |
$uploadedFileFactory | Psr\ | Factory to create uploaded files. |
createFromGlobals()
Section titled “createFromGlobals() ”public function createFromGlobals(): Psr\Http\Message\ServerRequestInterfaceBuilds a PSR request from the current SAPI globals and attaches a php://input body when available.
Copies HTTP_* and CGI content headers, server parameters, cookies, query parameters, and nested uploads.
Nonempty $_POST, and empty $_POST for POST form or multipart requests, become the parsed body. Other
bodies stay null for configured parsers or the URL-encoded fallback. Input stream failures leave the
factory’s original body unchanged.
Returns
Psr\Http\Message\ServerRequestInterface: Request created from the current globals.