RedirectResponse
in package
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
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)
$url
private
string
$url
Target URL for redirect
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
selfseeOther()
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
selfsend()
Send the redirect response.
public
send() : void
temporary()
Create a temporary redirect (302 Found).
public
static temporary(string $url) : self
Parameters
- $url : string
-
Target URL