interface ResponseFactory (View source)

Methods

make(array|string $content = '', int $status = 200, array $headers = [])

Create a new response instance.

noContent(int $status = 204, array $headers = [])

Create a new "no content" response.

view(string|array $view, array $data = [], int $status = 200, array $headers = [])

Create a new response for a given view.

json(mixed $data = [], int $status = 200, array $headers = [], int $options = 0)

Create a new JSON response instance.

jsonp(string $callback, mixed $data = [], int $status = 200, array $headers = [], int $options = 0)

Create a new JSONP response instance.

StreamedResponse
stream(callable $callback, int $status = 200, array $headers = [])

Create a new streamed response instance.

StreamedJsonResponse
streamJson(array $data, int $status = 200, array $headers = [], int $encodingOptions = 15)

Create a new streamed JSON response instance.

StreamedResponse
streamDownload(callable $callback, string|null $name = null, array $headers = [], string|null $disposition = 'attachment')

Create a new streamed response instance as a file download.

BinaryFileResponse
download(SplFileInfo|string $file, string|null $name = null, array $headers = [], string|null $disposition = 'attachment')

Create a new file download response.

BinaryFileResponse
file(SplFileInfo|string $file, array $headers = [])

Return the raw contents of a binary file.

redirectTo(string $path, int $status = 302, array $headers = [], bool|null $secure = null)

Create a new redirect response to the given path.

redirectToRoute(string $route, mixed $parameters = [], int $status = 302, array $headers = [])

Create a new redirect response to a named route.

redirectToAction(array|string $action, mixed $parameters = [], int $status = 302, array $headers = [])

Create a new redirect response to a controller action.

redirectGuest(string $path, int $status = 302, array $headers = [], bool|null $secure = null)

Create a new redirect response, while putting the current URL in the session.

redirectToIntended(string $default = '/', int $status = 302, array $headers = [], bool|null $secure = null)

Create a new redirect response to the previously intended location.

Details

Response make(array|string $content = '', int $status = 200, array $headers = [])

Create a new response instance.

Parameters

array|string $content
int $status
array $headers

Return Value

Response

Response noContent(int $status = 204, array $headers = [])

Create a new "no content" response.

Parameters

int $status
array $headers

Return Value

Response

Response view(string|array $view, array $data = [], int $status = 200, array $headers = [])

Create a new response for a given view.

Parameters

string|array $view
array $data
int $status
array $headers

Return Value

Response

JsonResponse json(mixed $data = [], int $status = 200, array $headers = [], int $options = 0)

Create a new JSON response instance.

Parameters

mixed $data
int $status
array $headers
int $options

Return Value

JsonResponse

JsonResponse jsonp(string $callback, mixed $data = [], int $status = 200, array $headers = [], int $options = 0)

Create a new JSONP response instance.

Parameters

string $callback
mixed $data
int $status
array $headers
int $options

Return Value

JsonResponse

StreamedResponse stream(callable $callback, int $status = 200, array $headers = [])

Create a new streamed response instance.

Parameters

callable $callback
int $status
array $headers

Return Value

StreamedResponse

StreamedJsonResponse streamJson(array $data, int $status = 200, array $headers = [], int $encodingOptions = 15)

Create a new streamed JSON response instance.

Parameters

array $data
int $status
array $headers
int $encodingOptions

Return Value

StreamedJsonResponse

StreamedResponse streamDownload(callable $callback, string|null $name = null, array $headers = [], string|null $disposition = 'attachment')

Create a new streamed response instance as a file download.

Parameters

callable $callback
string|null $name
array $headers
string|null $disposition

Return Value

StreamedResponse

BinaryFileResponse download(SplFileInfo|string $file, string|null $name = null, array $headers = [], string|null $disposition = 'attachment')

Create a new file download response.

Parameters

SplFileInfo|string $file
string|null $name
array $headers
string|null $disposition

Return Value

BinaryFileResponse

BinaryFileResponse file(SplFileInfo|string $file, array $headers = [])

Return the raw contents of a binary file.

Parameters

SplFileInfo|string $file
array $headers

Return Value

BinaryFileResponse

RedirectResponse redirectTo(string $path, int $status = 302, array $headers = [], bool|null $secure = null)

Create a new redirect response to the given path.

Parameters

string $path
int $status
array $headers
bool|null $secure

Return Value

RedirectResponse

RedirectResponse redirectToRoute(string $route, mixed $parameters = [], int $status = 302, array $headers = [])

Create a new redirect response to a named route.

Parameters

string $route
mixed $parameters
int $status
array $headers

Return Value

RedirectResponse

RedirectResponse redirectToAction(array|string $action, mixed $parameters = [], int $status = 302, array $headers = [])

Create a new redirect response to a controller action.

Parameters

array|string $action
mixed $parameters
int $status
array $headers

Return Value

RedirectResponse

RedirectResponse redirectGuest(string $path, int $status = 302, array $headers = [], bool|null $secure = null)

Create a new redirect response, while putting the current URL in the session.

Parameters

string $path
int $status
array $headers
bool|null $secure

Return Value

RedirectResponse

RedirectResponse redirectToIntended(string $default = '/', int $status = 302, array $headers = [], bool|null $secure = null)

Create a new redirect response to the previously intended location.

Parameters

string $default
int $status
array $headers
bool|null $secure

Return Value

RedirectResponse