Documentation

ResponseFactory
in package
implements ResponseFactory Uses Macroable

Interfaces, Classes and Traits

ResponseFactory

Table of Contents

$macros  : array<string|int, mixed>
The registered string macros.
$redirector  : Redirector
The redirector instance.
$view  : Factory
The view factory instance.
__call()  : mixed
Dynamically handle calls to the class.
__callStatic()  : mixed
Dynamically handle calls to the class.
__construct()  : void
Create a new response factory instance.
download()  : BinaryFileResponse
Create a new file download response.
file()  : BinaryFileResponse
Return the raw contents of a binary file.
hasMacro()  : bool
Checks if macro is registered.
json()  : JsonResponse
Return a new JSON response from the application.
jsonp()  : JsonResponse
Return a new JSONP response from the application.
macro()  : void
Register a custom macro.
make()  : Response
Return a new response from the application.
mixin()  : void
Mix another object into the class.
redirectGuest()  : RedirectResponse
Create a new redirect response, while putting the current URL in the session.
redirectTo()  : RedirectResponse
Create a new redirect response to the given path.
redirectToAction()  : RedirectResponse
Create a new redirect response to a controller action.
redirectToIntended()  : RedirectResponse
Create a new redirect response to the previously intended location.
redirectToRoute()  : RedirectResponse
Create a new redirect response to a named route.
stream()  : StreamedResponse
Return a new streamed response from the application.
view()  : Response
Return a new view response from the application.

Properties

$macros

The registered string macros.

protected static array<string|int, mixed> $macros = []

Methods

__call()

Dynamically handle calls to the class.

public __call(string $method, array<string|int, mixed> $parameters) : mixed
Parameters
$method : string
$parameters : array<string|int, mixed>
Tags
throws
BadMethodCallException
Return values
mixed

__callStatic()

Dynamically handle calls to the class.

public static __callStatic(string $method, array<string|int, mixed> $parameters) : mixed
Parameters
$method : string
$parameters : array<string|int, mixed>
Tags
throws
BadMethodCallException
Return values
mixed

download()

Create a new file download response.

public download(SplFileInfo|string $file[, string $name = null ][, array<string|int, mixed> $headers = [] ][, string|null $disposition = 'attachment' ]) : BinaryFileResponse
Parameters
$file : SplFileInfo|string
$name : string = null
$headers : array<string|int, mixed> = []
$disposition : string|null = 'attachment'
Return values
BinaryFileResponse

file()

Return the raw contents of a binary file.

public file(SplFileInfo|string $file[, array<string|int, mixed> $headers = [] ]) : BinaryFileResponse
Parameters
$file : SplFileInfo|string
$headers : array<string|int, mixed> = []
Return values
BinaryFileResponse

hasMacro()

Checks if macro is registered.

public static hasMacro(string $name) : bool
Parameters
$name : string
Return values
bool

json()

Return a new JSON response from the application.

public json([mixed $data = [] ][, int $status = 200 ][, array<string|int, mixed> $headers = [] ], int $options) : JsonResponse
Parameters
$data : mixed = []
$status : int = 200
$headers : array<string|int, mixed> = []
$options : int
Return values
JsonResponse

jsonp()

Return a new JSONP response from the application.

public jsonp(string $callback[, mixed $data = [] ][, int $status = 200 ][, array<string|int, mixed> $headers = [] ], int $options) : JsonResponse
Parameters
$callback : string
$data : mixed = []
$status : int = 200
$headers : array<string|int, mixed> = []
$options : int
Return values
JsonResponse

macro()

Register a custom macro.

public static macro(string $name, object|callable $macro) : void
Parameters
$name : string
$macro : object|callable
Return values
void

make()

Return a new response from the application.

public make([string $content = '' ][, int $status = 200 ][, array<string|int, mixed> $headers = [] ]) : Response
Parameters
$content : string = ''
$status : int = 200
$headers : array<string|int, mixed> = []
Return values
Response

mixin()

Mix another object into the class.

public static mixin(object $mixin) : void
Parameters
$mixin : object
Return values
void

redirectGuest()

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

public redirectGuest(string $path[, int $status = 302 ][, array<string|int, mixed> $headers = [] ][, bool|null $secure = null ]) : RedirectResponse
Parameters
$path : string
$status : int = 302
$headers : array<string|int, mixed> = []
$secure : bool|null = null
Return values
RedirectResponse

redirectTo()

Create a new redirect response to the given path.

public redirectTo(string $path[, int $status = 302 ][, array<string|int, mixed> $headers = [] ][, bool|null $secure = null ]) : RedirectResponse
Parameters
$path : string
$status : int = 302
$headers : array<string|int, mixed> = []
$secure : bool|null = null
Return values
RedirectResponse

redirectToAction()

Create a new redirect response to a controller action.

public redirectToAction(string $action[, array<string|int, mixed> $parameters = [] ][, int $status = 302 ][, array<string|int, mixed> $headers = [] ]) : RedirectResponse
Parameters
$action : string
$parameters : array<string|int, mixed> = []
$status : int = 302
$headers : array<string|int, mixed> = []
Return values
RedirectResponse

redirectToIntended()

Create a new redirect response to the previously intended location.

public redirectToIntended([string $default = '/' ][, int $status = 302 ][, array<string|int, mixed> $headers = [] ][, bool|null $secure = null ]) : RedirectResponse
Parameters
$default : string = '/'
$status : int = 302
$headers : array<string|int, mixed> = []
$secure : bool|null = null
Return values
RedirectResponse

redirectToRoute()

Create a new redirect response to a named route.

public redirectToRoute(string $route[, array<string|int, mixed> $parameters = [] ][, int $status = 302 ][, array<string|int, mixed> $headers = [] ]) : RedirectResponse
Parameters
$route : string
$parameters : array<string|int, mixed> = []
$status : int = 302
$headers : array<string|int, mixed> = []
Return values
RedirectResponse

stream()

Return a new streamed response from the application.

public stream(Closure $callback[, int $status = 200 ][, array<string|int, mixed> $headers = [] ]) : StreamedResponse
Parameters
$callback : Closure
$status : int = 200
$headers : array<string|int, mixed> = []
Return values
StreamedResponse

view()

Return a new view response from the application.

public view(string $view[, array<string|int, mixed> $data = [] ][, int $status = 200 ][, array<string|int, mixed> $headers = [] ]) : Response
Parameters
$view : string
$data : array<string|int, mixed> = []
$status : int = 200
$headers : array<string|int, mixed> = []
Return values
Response

Search results