Symfony2 API
Class

Symfony\Component\HttpFoundation\RedirectResponse

class RedirectResponse extends Response

RedirectResponse represents an HTTP response doing a redirect.

Methods

__construct(string $url, integer $status = 302, array $headers = array())

Constructor.

static Response create($url = '', integer $status = 302, array $headers = array())

Factory method for chainability

string getTargetUrl()

Returns the target URL.

RedirectResponse setTargetUrl(string $url)

Sets the redirect target of this response.

Details

at line 38
public __construct(string $url, integer $status = 302, array $headers = array())

Constructor.

Parameters

string $url The URL to redirect to
integer $status The status code (302 by default)
array $headers The headers (Location is always set to the given url)

Exceptions

InvalidArgumentException When the HTTP status code is not valid

See also

http://tools.ietf.org/html/rfc2616#section-10.3

at line 56
static public Response create($url = '', integer $status = 302, array $headers = array())

Factory method for chainability

Example:

return Response::create($body, 200)
->setSharedMaxAge(300);

Parameters

$url
integer $status The response status code
array $headers An array of response headers

Return Value

Response

at line 66
public string getTargetUrl()

Returns the target URL.

Return Value

string target URL

at line 80
public RedirectResponse setTargetUrl(string $url)

Sets the redirect target of this response.

Parameters

string $url The URL to redirect to

Return Value

RedirectResponse The current response.

Exceptions

InvalidArgumentException