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

HTTPResponse
in package

FinalYes

Typed outbound-HTTP response. Returned by every Http::* call.

Fields are public + readonly — call sites do $r->status / $r->body directly. json() decodes the body once (no caching — small enough cost; cache yourself if a hot loop reads it many times).

Table of Contents

Properties

$body  : string
$error  : Throwable|null
$headers  : array<string|int, mixed>
$status  : int

Methods

__construct()  : mixed
failed()  : bool
Whether the request failed at the transport layer (network, DNS, timeout, TLS).
json()  : mixed
ok()  : bool
2xx response — successful by convention.

Properties

$body read-only

public string $body

$error read-only

public Throwable|null $error = null

$headers read-only

public array<string|int, mixed> $headers = []

$status read-only

public int $status

Methods

__construct()

public __construct(int $status, string $body[, array<string, string> $headers = [] ][, Throwable|null $error = null ]) : mixed
Parameters
$status : int
$body : string
$headers : array<string, string> = []
$error : Throwable|null = null

failed()

Whether the request failed at the transport layer (network, DNS, timeout, TLS).

public failed() : bool
Return values
bool

json()

public json() : mixed
Return values
mixed

JSON-decoded body, or null when not valid JSON

ok()

2xx response — successful by convention.

public ok() : bool
Return values
bool
On this page