Documentation

RedirectResponse implements ResponseInterface

HTTP redirect response.

Encapsulates a redirect response with URL and status code. Can be returned from controllers and sent by the router.

Tags
since
3.0.0

Table of Contents

Interfaces

ResponseInterface
Interface for HTTP response objects.

Properties

$statusCode  : int
$url  : string

Methods

__construct()  : mixed
Create a new redirect response.
getStatusCode()  : int
Get the HTTP status code.
getUrl()  : string
Get the redirect URL.
permanent()  : self
Create a permanent redirect (301 Moved Permanently).
seeOther()  : self
Create a "see other" redirect (303 See Other).
send()  : void
Send the redirect response.
temporary()  : self
Create a temporary redirect (302 Found).

Properties

$statusCode

private int $statusCode

HTTP status code (302 for temporary, 301 for permanent)

Methods

__construct()

Create a new redirect response.

public __construct(string $url[, int $statusCode = 302 ]) : mixed
Parameters
$url : string

Target URL

$statusCode : int = 302

HTTP status code (default: 302 Found)

getStatusCode()

Get the HTTP status code.

public getStatusCode() : int
Return values
int

HTTP status code

getUrl()

Get the redirect URL.

public getUrl() : string
Return values
string

Target URL

permanent()

Create a permanent redirect (301 Moved Permanently).

public static permanent(string $url) : self
Parameters
$url : string

Target URL

Return values
self

seeOther()

Create a "see other" redirect (303 See Other).

public static seeOther(string $url) : self

Used after POST to redirect to a GET endpoint.

Parameters
$url : string

Target URL

Return values
self

temporary()

Create a temporary redirect (302 Found).

public static temporary(string $url) : self
Parameters
$url : string

Target URL

Return values
self

        
On this page

Search results