Esc
API Index — Namespaces, Packages, Reports, Indices
LazyServerRequest
in package
implements
ServerRequestInterface
Lazy PSR-7 ServerRequest — defers expensive hydration until accessed.
The full OpenSwoole\Core\Psr\ServerRequest::from() creates Uri, Stream, UploadedFile objects and copies all headers/params on every request. Most middleware only calls getMethod() and getHeaderLine() — this wrapper returns those from the native OpenSwoole request with zero allocation.
Only when a method requiring the full PSR-7 object is called (getBody(), getUri(), withHeader(), etc.) does it hydrate the underlying object.
Table of Contents
Interfaces
- ServerRequestInterface
Properties
Methods
- __construct() : mixed
- getAttribute() : mixed
- getAttributes() : array<string, mixed>
- getBody() : StreamInterface
- getCookieParams() : array<string, string>
- getHeader() : array<string|int, string>
- getHeaderLine() : string
- getHeaders() : array<string, array<string|int, string>>
- getMethod() : string
- getParsedBody() : array<string, mixed>|object|null
- getProtocolVersion() : string
- getQueryParams() : array<string, mixed>
- getRequestTarget() : string
- getServerParams() : array<string, mixed>
- getUploadedFiles() : array<string, UploadedFileInterface>
- getUri() : UriInterface
- hasHeader() : bool
- withAddedHeader() : static
- withAttribute() : static
- withBody() : static
- withCookieParams() : static
- withHeader() : static
- withMethod() : static
- withoutAttribute() : static
- withoutHeader() : static
- withParsedBody() : static
- withProtocolVersion() : static
- withQueryParams() : static
- withRequestTarget() : static
- withUploadedFiles() : static
- withUri() : static
- hydrate() : ServerRequestInterface
Properties
$hydrated
private
ServerRequestInterface|null
$hydrated
= null
$native
private
Request
$native
Methods
__construct()
public
__construct(Request $native) : mixed
Parameters
- $native : Request
getAttribute()
public
getAttribute(string $name[, mixed $default = null ]) : mixed
Parameters
- $name : string
- $default : mixed = null
getAttributes()
public
getAttributes() : array<string, mixed>
Return values
array<string, mixed>getBody()
public
getBody() : StreamInterface
Return values
StreamInterfacegetCookieParams()
public
getCookieParams() : array<string, string>
Return values
array<string, string>getHeader()
public
getHeader(string $name) : array<string|int, string>
Parameters
- $name : string
Return values
array<string|int, string>getHeaderLine()
public
getHeaderLine(string $name) : string
Parameters
- $name : string
Return values
stringgetHeaders()
public
getHeaders() : array<string, array<string|int, string>>
Return values
array<string, array<string|int, string>>getMethod()
public
getMethod() : string
Return values
stringgetParsedBody()
public
getParsedBody() : array<string, mixed>|object|null
Return values
array<string, mixed>|object|nullgetProtocolVersion()
public
getProtocolVersion() : string
Return values
stringgetQueryParams()
public
getQueryParams() : array<string, mixed>
Return values
array<string, mixed>getRequestTarget()
public
getRequestTarget() : string
Return values
stringgetServerParams()
public
getServerParams() : array<string, mixed>
Return values
array<string, mixed>getUploadedFiles()
public
getUploadedFiles() : array<string, UploadedFileInterface>
Return values
array<string, UploadedFileInterface>getUri()
public
getUri() : UriInterface
Return values
UriInterfacehasHeader()
public
hasHeader(string $name) : bool
Parameters
- $name : string
Return values
boolwithAddedHeader()
public
withAddedHeader(string $name, mixed $value) : static
Parameters
- $name : string
- $value : mixed
Return values
staticwithAttribute()
public
withAttribute(string $name, mixed $value) : static
Parameters
- $name : string
- $value : mixed
Return values
staticwithBody()
public
withBody(StreamInterface $body) : static
Parameters
- $body : StreamInterface
Return values
staticwithCookieParams()
public
withCookieParams(array<string, string> $cookies) : static
Parameters
- $cookies : array<string, string>
Return values
staticwithHeader()
public
withHeader(string $name, mixed $value) : static
Parameters
- $name : string
- $value : mixed
Return values
staticwithMethod()
public
withMethod(string $method) : static
Parameters
- $method : string
Return values
staticwithoutAttribute()
public
withoutAttribute(string $name) : static
Parameters
- $name : string
Return values
staticwithoutHeader()
public
withoutHeader(string $name) : static
Parameters
- $name : string
Return values
staticwithParsedBody()
public
withParsedBody(array<string, mixed>|object|null $data) : static
Parameters
- $data : array<string, mixed>|object|null
Return values
staticwithProtocolVersion()
public
withProtocolVersion(string $version) : static
Parameters
- $version : string
Return values
staticwithQueryParams()
public
withQueryParams(array<string, mixed> $query) : static
Parameters
- $query : array<string, mixed>
Return values
staticwithRequestTarget()
public
withRequestTarget(string $requestTarget) : static
Parameters
- $requestTarget : string
Return values
staticwithUploadedFiles()
public
withUploadedFiles(array<string, UploadedFileInterface> $uploadedFiles) : static
Parameters
- $uploadedFiles : array<string, UploadedFileInterface>
Return values
staticwithUri()
public
withUri(UriInterface $uri[, bool $preserveHost = false ]) : static
Parameters
- $uri : UriInterface
- $preserveHost : bool = false
Return values
statichydrate()
private
hydrate() : ServerRequestInterface