class Response (View source)

Methods

static int
status(int $code = 0)

Get or set status code and return previous status code.

static 
header(string $name, string|null $value, bool $replace = true)

Shortcut for set header Note: While PHP internally discards headers containing line breaks and issues a warning, such content is explicitly forbidden by this function. An exception will now be thrown if line breaks are detected, preventing both silent issues and potential misinterpretations of header behavior.

static 
type(string|null $value, string|null $charset = null)

Set Content-Type header or remove previously headers

static 
cache(int|string $seconds, int|string $modified = 0)

Set HTTP cache or no-cache Note: $seconds and $modified accept English textual datetime descriptions (e.g., 'now', '+1 day', 'last Monday').

static 
download(string $name, int $length = 0)

Force download current response

Details

static int status(int $code = 0)

Get or set status code and return previous status code.

Note: If the status has changed, the Event::on('changestatus') event will be triggered

Parameters

int $code

Return Value

int

static header(string $name, string|null $value, bool $replace = true)

Shortcut for set header Note: While PHP internally discards headers containing line breaks and issues a warning, such content is explicitly forbidden by this function. An exception will now be thrown if line breaks are detected, preventing both silent issues and potential misinterpretations of header behavior.

Parameters

string $name
string|null $value
bool $replace

Exceptions

Exception

static type(string|null $value, string|null $charset = null)

Set Content-Type header or remove previously headers

Parameters

string|null $value
string|null $charset

static cache(int|string $seconds, int|string $modified = 0)

Set HTTP cache or no-cache Note: $seconds and $modified accept English textual datetime descriptions (e.g., 'now', '+1 day', 'last Monday').

Parameters

int|string $seconds

Set cache in seconds. If $seconds is less than 1, caching is disabled

int|string $modified

Optional. Last modified timestamp. Defaults to the current time

Exceptions

Exception

static download(string $name, int $length = 0)

Force download current response

Parameters

string $name

File name for download (e.g., "report.pdf")

int $length

Optional. File size in bytes