Skip to content
PHP Ecosystem
Explore

ServerRequestCreator

API reference › PSR bridge › creator › ServerRequestCreator

final classyii2\extensions\psrbridge\creator\ServerRequestCreator
Sourcesrc/creator/ServerRequestCreator.php

Creates PSR-7 server requests from PHP globals.

MethodDescriptionDefined 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
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

ParameterTypeDescription
$serverRequestFactoryPsr\Http\Message\ServerRequestFactoryInterfaceFactory to create server requests.
$streamFactoryPsr\Http\Message\StreamFactoryInterfaceFactory to create streams.
$uploadedFileFactoryPsr\Http\Message\UploadedFileFactoryInterfaceFactory to create uploaded files.
public function createFromGlobals(): Psr\Http\Message\ServerRequestInterface

Builds 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.