trait ResponseTrait

Properties

mixed $original

The original content of the response.

Throwable|null $exception

The exception that triggered the error response (if applicable).

Methods

int
status()

Get the status code for the response.

string
statusText()

Get the status text for the response.

string
content()

Get the content of the response.

mixed
getOriginalContent()

Get the original response content.

header(string $key, array|string $values, bool $replace = true)

Set a header on the Response.

withHeaders(HeaderBag|array $headers)

Add an array of headers to the response.

withoutHeader(array|string $key)

Remove a header(s) from the response.

cookie(mixed $cookie)

Add a cookie to the response.

withCookie(mixed $cookie)

Add a cookie to the response.

withoutCookie(mixed $cookie, string|null $path = null, string|null $domain = null)

Expire a cookie when sending the response.

string|null
getCallback()

Get the callback of the response.

withException(Throwable $e)

Set the exception to attach to the response.

never
throwResponse()

Throw the response in a HttpResponseException instance.

Details

at line 26
int status()

Get the status code for the response.

Return Value

int

at line 34
string statusText()

Get the status text for the response.

Return Value

string

at line 42
string content()

Get the content of the response.

Return Value

string

at line 50
mixed getOriginalContent()

Get the original response content.

Return Value

mixed

at line 62
ResponseTrait header(string $key, array|string $values, bool $replace = true)

Set a header on the Response.

Parameters

string $key
array|string $values
bool $replace

Return Value

ResponseTrait

at line 74
ResponseTrait withHeaders(HeaderBag|array $headers)

Add an array of headers to the response.

Parameters

HeaderBag|array $headers

Return Value

ResponseTrait

at line 92
ResponseTrait withoutHeader(array|string $key)

Remove a header(s) from the response.

Parameters

array|string $key

Return Value

ResponseTrait

Add a cookie to the response.

Parameters

mixed $cookie

Return Value

ResponseTrait

at line 116
ResponseTrait withCookie(mixed $cookie)

Add a cookie to the response.

Parameters

mixed $cookie

Return Value

ResponseTrait

at line 132
ResponseTrait withoutCookie(mixed $cookie, string|null $path = null, string|null $domain = null)

Expire a cookie when sending the response.

Parameters

mixed $cookie
string|null $path
string|null $domain

Return Value

ResponseTrait

at line 146
string|null getCallback()

Get the callback of the response.

Return Value

string|null

at line 156
ResponseTrait withException(Throwable $e)

Set the exception to attach to the response.

Parameters

Throwable $e

Return Value

ResponseTrait

at line 168
never throwResponse()

Throw the response in a HttpResponseException instance.

Return Value

never

Exceptions

HttpResponseException