class Response implements ArrayAccess, Stringable (View source)
| DeterminesStatusCode | |
| Macroable |
| static protected array | $macros | The registered string macros. | from Macroable |
| protected ResponseInterface | $response | The underlying PSR response. | |
| protected array | $decoded | The decoded JSON response. | |
| CookieJar | $cookies | The request cookies. | |
| TransferStats|null | $transferStats | The transfer stats for the request. |
| bool | ok()
Determine if the response code was 200 "OK" response. | from DeterminesStatusCode |
| bool | created()
Determine if the response code was 201 "Created" response. | from DeterminesStatusCode |
| bool | accepted()
Determine if the response code was 202 "Accepted" response. | from DeterminesStatusCode |
| bool | noContent(int $status = 204)
Determine if the response code was the given status code and the body has no content. | from DeterminesStatusCode |
| bool | movedPermanently()
Determine if the response code was a 301 "Moved Permanently". | from DeterminesStatusCode |
| bool | found()
Determine if the response code was a 302 "Found" response. | from DeterminesStatusCode |
| bool | notModified()
Determine if the response code was a 304 "Not Modified" response. | from DeterminesStatusCode |
| bool | badRequest()
Determine if the response was a 400 "Bad Request" response. | from DeterminesStatusCode |
| bool | unauthorized()
Determine if the response was a 401 "Unauthorized" response. | from DeterminesStatusCode |
| bool | paymentRequired()
Determine if the response was a 402 "Payment Required" response. | from DeterminesStatusCode |
| bool | forbidden()
Determine if the response was a 403 "Forbidden" response. | from DeterminesStatusCode |
| bool | notFound()
Determine if the response was a 404 "Not Found" response. | from DeterminesStatusCode |
| bool | requestTimeout()
Determine if the response was a 408 "Request Timeout" response. | from DeterminesStatusCode |
| bool | conflict()
Determine if the response was a 409 "Conflict" response. | from DeterminesStatusCode |
| bool | unprocessableContent()
Determine if the response was a 422 "Unprocessable Content" response. | from DeterminesStatusCode |
| bool | unprocessableEntity()
Determine if the response was a 422 "Unprocessable Content" response. | from DeterminesStatusCode |
| bool | tooManyRequests()
Determine if the response was a 429 "Too Many Requests" response. | from DeterminesStatusCode |
| static void | macro(string $name, object|callable $macro)
Register a custom macro. | from Macroable |
| static void | mixin(object $mixin, bool $replace = true)
Mix another object into the class. | from Macroable |
| static bool | hasMacro(string $name)
Checks if macro is registered. | from Macroable |
| static void | flushMacros()
Flush the existing macros. | from Macroable |
| static mixed | __callStatic(string $method, array $parameters)
Dynamically handle calls to the class. | from Macroable |
| mixed | __call(string $method, array $parameters)
Dynamically proxy other methods to the underlying response. | |
| void | __construct(MessageInterface $response)
Create a new response instance. | |
| string | body()
Get the body of the response. | |
| mixed | json(string|null $key = null, mixed $default = null)
Get the JSON decoded body of the response as an array or scalar value. | |
| object|null | object()
Get the JSON decoded body of the response as an object. | |
| Collection | collect(string|null $key = null)
Get the JSON decoded body of the response as a collection. | |
| string | header(string $header)
Get a header from the response. | |
| array | headers()
Get the headers from the response. | |
| int | status()
Get the status code of the response. | |
| string | reason()
Get the reason phrase of the response. | |
| UriInterface|null | effectiveUri()
Get the effective URI of the response. | |
| bool | successful()
Determine if the request was successful. | |
| bool | redirect()
Determine if the response was a redirect. | |
| bool | failed()
Determine if the response indicates a client or server error occurred. | |
| bool | clientError()
Determine if the response indicates a client error occurred. | |
| bool | serverError()
Determine if the response indicates a server error occurred. | |
| $this | onError(callable $callback)
Execute the given callback if there was a server or client error. | |
| CookieJar | cookies()
Get the response cookies. | |
| array | handlerStats()
Get the handler stats of the response. | |
| $this | close()
Close the stream and any underlying resources. | |
| ResponseInterface | toPsrResponse()
Get the underlying PSR response for the response. | |
| RequestException|null | toException()
Create an exception if a server or client error occurred. | |
| $this | throw()
Throw an exception if a server or client error occurred. | |
| $this | throwIf(Closure|bool $condition)
Throw an exception if a server or client error occurred and the given condition evaluates to true. | |
| $this | throwIfStatus(callable|int $statusCode)
Throw an exception if the response status code matches the given code. | |
| $this | throwUnlessStatus(callable|int $statusCode)
Throw an exception unless the response status code matches the given code. | |
| $this | throwIfClientError()
Throw an exception if the response status code is a 4xx level code. | |
| $this | throwIfServerError()
Throw an exception if the response status code is a 5xx level code. | |
| bool | offsetExists(string $offset)
Determine if the given offset exists. | |
| mixed | offsetGet(string $offset)
Get the value for a given offset. | |
| void | offsetSet(string $offset, mixed $value)
Set the value at the given offset. | |
| void | offsetUnset(string $offset)
Unset the value at the given offset. | |
| string | __toString()
Get the body of the response. |
Determine if the response code was 200 "OK" response.
Determine if the response code was 201 "Created" response.
Determine if the response code was 202 "Accepted" response.
Determine if the response code was the given status code and the body has no content.
Determine if the response code was a 301 "Moved Permanently".
Determine if the response code was a 302 "Found" response.
Determine if the response code was a 304 "Not Modified" response.
Determine if the response was a 400 "Bad Request" response.
Determine if the response was a 401 "Unauthorized" response.
Determine if the response was a 402 "Payment Required" response.
Determine if the response was a 403 "Forbidden" response.
Determine if the response was a 404 "Not Found" response.
Determine if the response was a 408 "Request Timeout" response.
Determine if the response was a 409 "Conflict" response.
Determine if the response was a 422 "Unprocessable Content" response.
Determine if the response was a 422 "Unprocessable Content" response.
Determine if the response was a 429 "Too Many Requests" response.
Register a custom macro.
Mix another object into the class.
Checks if macro is registered.
Flush the existing macros.
Dynamically handle calls to the class.
Dynamically proxy other methods to the underlying response.
Create a new response instance.
Get the body of the response.
Get the JSON decoded body of the response as an array or scalar value.
Get the JSON decoded body of the response as an object.
Get the JSON decoded body of the response as a collection.
Get a header from the response.
Get the headers from the response.
Get the status code of the response.
Get the reason phrase of the response.
Get the effective URI of the response.
Determine if the request was successful.
Determine if the response was a redirect.
Determine if the response indicates a client or server error occurred.
Determine if the response indicates a client error occurred.
Determine if the response indicates a server error occurred.
Execute the given callback if there was a server or client error.
Get the response cookies.
Get the handler stats of the response.
Close the stream and any underlying resources.
Get the underlying PSR response for the response.
Create an exception if a server or client error occurred.
Throw an exception if a server or client error occurred.
Throw an exception if a server or client error occurred and the given condition evaluates to true.
Throw an exception if the response status code matches the given code.
Throw an exception unless the response status code matches the given code.
Throw an exception if the response status code is a 4xx level code.
Throw an exception if the response status code is a 5xx level code.
Determine if the given offset exists.
Get the value for a given offset.
Set the value at the given offset.
Unset the value at the given offset.
Get the body of the response.
© Taylor Otwell
Licensed under the MIT License.
Laravel is a trademark of Taylor Otwell.
https://laravel.com/api/11.x/Illuminate/Http/Client/Response.html