Alpha ZealPHP is early-stage and under active development. APIs may change between minor versions until v1.0. Feedback and bug reports welcome on GitHub.
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

$hydrated  : ServerRequestInterface|null
$native  : Request

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

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>

getCookieParams()

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
string

getHeaders()

public getHeaders() : array<string, array<string|int, string>>
Return values
array<string, array<string|int, string>>

getParsedBody()

public getParsedBody() : array<string, mixed>|object|null
Return values
array<string, mixed>|object|null

getProtocolVersion()

public getProtocolVersion() : string
Return values
string

getQueryParams()

public getQueryParams() : array<string, mixed>
Return values
array<string, mixed>

getServerParams()

public getServerParams() : array<string, mixed>
Return values
array<string, mixed>

getUploadedFiles()

public getUploadedFiles() : array<string, UploadedFileInterface>
Return values
array<string, UploadedFileInterface>

hasHeader()

public hasHeader(string $name) : bool
Parameters
$name : string
Return values
bool

withAddedHeader()

public withAddedHeader(string $name, mixed $value) : static
Parameters
$name : string
$value : mixed
Return values
static

withAttribute()

public withAttribute(string $name, mixed $value) : static
Parameters
$name : string
$value : mixed
Return values
static

withBody()

public withBody(StreamInterface $body) : static
Parameters
$body : StreamInterface
Return values
static

withCookieParams()

public withCookieParams(array<string, string> $cookies) : static
Parameters
$cookies : array<string, string>
Return values
static

withHeader()

public withHeader(string $name, mixed $value) : static
Parameters
$name : string
$value : mixed
Return values
static

withMethod()

public withMethod(string $method) : static
Parameters
$method : string
Return values
static

withoutAttribute()

public withoutAttribute(string $name) : static
Parameters
$name : string
Return values
static

withoutHeader()

public withoutHeader(string $name) : static
Parameters
$name : string
Return values
static

withParsedBody()

public withParsedBody(array<string, mixed>|object|null $data) : static
Parameters
$data : array<string, mixed>|object|null
Return values
static

withProtocolVersion()

public withProtocolVersion(string $version) : static
Parameters
$version : string
Return values
static

withQueryParams()

public withQueryParams(array<string, mixed> $query) : static
Parameters
$query : array<string, mixed>
Return values
static

withRequestTarget()

public withRequestTarget(string $requestTarget) : static
Parameters
$requestTarget : string
Return values
static

withUploadedFiles()

public withUploadedFiles(array<string, UploadedFileInterface$uploadedFiles) : static
Parameters
$uploadedFiles : array<string, UploadedFileInterface>
Return values
static

withUri()

public withUri(UriInterface $uri[, bool $preserveHost = false ]) : static
Parameters
$uri : UriInterface
$preserveHost : bool = false
Return values
static

hydrate()

private hydrate() : ServerRequestInterface
Return values
ServerRequestInterface
On this page