HttpRequest
extends InputRequest
in package
Table of Contents
Properties
- $cookies : array<string|int, mixed>
- The cookies sent to this route
- $defaultController : HttpController|null
- $domain : string
- The request host domain name
- $files : array<string|int, mixed>
- The uploaded files sent to this route
- $headers : array<string|int, mixed>
- The headers sent to this route
- $input : array<string|int, mixed>|string|null
- The input (like stdin)
- $inputType : string
- The input content type
- $mainRequest : static|null
- The current main request
- $method : string
- The used method for this request
- $parameters : array<string|int, mixed>
- The input parameters (inline parameters)
- $path : string
- The path
- $pathValues : array<string|int, mixed>
- The values in path
- $route : ControllerRoute|null
- The found route for this request A request could exist without any route (e.g. Route initialization failed)
- $scheme : string
- The scheme used to access this route
Methods
- __construct() : mixed
- Constructor
- __toString() : string
- Get this request as string
- cloneWithPath() : InputRequest
- Clone this request using another path (expecting a sub path)
- findFirstMatchingRoute() : array<string|int, mixed>
- Find a matching route according to the request
- formatUrl() : string
- Generate new URL for this request
- generateFromEnvironment() : HttpRequest
- Generate HttpRequest from environment
- getAllData() : array<string|int, mixed>
- Get all input data
- getArrayData() : mixed
- Get the data by key with array as default
- getConfigPostMaxSize() : int
- Get php config for max post size
- getController() : AbstractController
- Get running controller
- getCookies() : array<string|int, mixed>
- Get the cookies
- getData() : mixed
- Get a data by $key, assuming $default
- getDefaultController() : HttpController
- getDomain() : string
- Get the host domain
- getFiles() : array<string|int, mixed>
- Get the uploaded files
- getHeaderContentLength() : int|null
- Get the header Content-Length
- getHeaders() : array<string|int, mixed>
- Get the headers
- getInput() : array<string|int, mixed>
- Get input
- getInputType() : string
- Get the input type
- getInputValue() : mixed
- Get the input by $key, assuming $default value
- getMainHttpRequest() : HttpRequest|null
- Get the main http request or null if not an HTTP request
- getMainRequest() : InputRequest|null
- Get the main input request
- getMainRequest() : HttpRequest
- Get the main input request
- getMethod() : string
- Get the method
- getOption() : mixed
- Get the option by $key, assuming $default value
- getParameter() : mixed
- Get the parameter by $key, assuming $default value
- getParameters() : array<string|int, mixed>
- Get all parameters
- getPath() : string
- Get the path
- getPathValue() : string|null
- Get path value by $key, assuming $default
- getPathValues() : array<string|int, mixed>
- Get path values
- getRoute() : ControllerRoute|null
- Get the route to this request
- getRouteClass() : string
- Get the name of the route class associated to a HttpRequest
- getRouteName() : string
- Get the route name to this request
- getRoutes() : array<string|int, HttpRoute>
- Get all available routes
- getScheme() : string
- Get the scheme
- getUrl() : string
- Get the URL used for this request
- handleCurrentRequest() : void
- Handle the current request as a HttpRequest one This method ends the script
- hasArrayData() : bool
- Test if data $key is an array
- hasData() : bool
- Test if data contains the $key
- hasDataKey() : bool
- Test if path contains a value and return it as parameter
- hasInput() : bool
- Test if request has any input
- hasInputValue() : bool
- Test if input $key exists in this request
- hasParameter() : bool
- Test if parameter $key exists in this request
- hasPathValue() : bool
- Check request has path value $key
- isDelete() : bool
- Test if this is a DELETE request
- isGet() : bool
- Test if this is a GET request
- isPost() : bool
- Test if this is a POST request
- isPostSiteOverLimit() : bool
- Test incoming request is over php max post size
- isPut() : bool
- Test if this is a PUT request
- matchPath() : string
- Test path is matching regex
- process() : OutputResponse
- Process the request by finding a route and processing it
- processRoute() : OutputResponse
- Process the given route
- redirect() : RedirectHttpResponse|null
- Redirect response to $route
- setRoute() : InputRequest
- Set the route to this request
- showFallbackError() : void
- setContent() : HttpRequest
- Set the content (input & input type)
- setCookies() : HttpRequest
- Set the cookies
- setDomain() : $this
- Set the host domain
- setFiles() : HttpRequest
- Set the uploaded files
- setHeaders() : HttpRequest
- Set the headers
- setInput() : InputRequest
- Set the input
- setInputType() : HttpRequest
- Set the input type
- setMethod() : HttpRequest
- Set the method
- setParameters() : InputRequest
- Set the parameters
- setPath() : InputRequest
- Set the path
- setScheme() : HttpRequest
- Set the scheme
Properties
$cookies
The cookies sent to this route
protected
array<string|int, mixed>
$cookies
= []
$defaultController
protected
static HttpController|null
$defaultController
= null
$domain
The request host domain name
protected
string
$domain
$files
The uploaded files sent to this route
protected
array<string|int, mixed>
$files
= []
$headers
The headers sent to this route
protected
array<string|int, mixed>
$headers
= []
$input
The input (like stdin)
protected
array<string|int, mixed>|string|null
$input
$inputType
The input content type
protected
string
$inputType
Tags
$mainRequest
The current main request
protected
static static|null
$mainRequest
= null
$method
The used method for this request
protected
string
$method
$parameters
The input parameters (inline parameters)
protected
array<string|int, mixed>
$parameters
$path
The path
protected
string
$path
$pathValues
The values in path
protected
array<string|int, mixed>
$pathValues
$route
The found route for this request A request could exist without any route (e.g. Route initialization failed)
protected
ControllerRoute|null
$route
= null
$scheme
The scheme used to access this route
protected
string
$scheme
Methods
__construct()
Constructor
public
__construct(string $method, string $path, array<string|int, mixed> $parameters[, array<string|int, mixed>|null $input = null ]) : mixed
Parameters
- $method : string
- $path : string
- $parameters : array<string|int, mixed>
- $input : array<string|int, mixed>|null = null
__toString()
Get this request as string
public
__toString() : string
Return values
stringcloneWithPath()
Clone this request using another path (expecting a sub path)
public
cloneWithPath(string $path) : InputRequest
Parameters
- $path : string
Return values
InputRequestfindFirstMatchingRoute()
Find a matching route according to the request
public
findFirstMatchingRoute() : array<string|int, mixed>
Return values
array<string|int, mixed>formatUrl()
Generate new URL for this request
public
formatUrl([array<string|int, mixed> $values = [] ]) : string
Parameters
- $values : array<string|int, mixed> = []
-
Force parameters
Return values
stringgenerateFromEnvironment()
Generate HttpRequest from environment
public
static generateFromEnvironment() : HttpRequest
Return values
HttpRequestgetAllData()
Get all input data
public
getAllData() : array<string|int, mixed>
Return values
array<string|int, mixed>getArrayData()
Get the data by key with array as default
public
getArrayData(string $key) : mixed
Parameters
- $key : string
getConfigPostMaxSize()
Get php config for max post size
public
getConfigPostMaxSize() : int
Tags
Return values
intgetController()
Get running controller
public
getController() : AbstractController
Return values
AbstractControllergetCookies()
Get the cookies
public
getCookies() : array<string|int, mixed>
Return values
array<string|int, mixed>getData()
Get a data by $key, assuming $default
public
getData(string $key[, mixed $default = null ]) : mixed
Parameters
- $key : string
- $default : mixed = null
getDefaultController()
public
static getDefaultController() : HttpController
Return values
HttpControllergetDomain()
Get the host domain
public
getDomain() : string
Return values
stringgetFiles()
Get the uploaded files
public
getFiles() : array<string|int, mixed>
Return values
array<string|int, mixed>getHeaderContentLength()
Get the header Content-Length
public
getHeaderContentLength() : int|null
Return values
int|nullgetHeaders()
Get the headers
public
getHeaders() : array<string|int, mixed>
Return values
array<string|int, mixed>getInput()
Get input
public
getInput() : array<string|int, mixed>
Return values
array<string|int, mixed>getInputType()
Get the input type
public
getInputType() : string
Return values
stringgetInputValue()
Get the input by $key, assuming $default value
public
getInputValue(string $key[, mixed $default = null ]) : mixed
Parameters
- $key : string
- $default : mixed = null
getMainHttpRequest()
Get the main http request or null if not an HTTP request
public
static getMainHttpRequest() : HttpRequest|null
Return values
HttpRequest|nullgetMainRequest()
Get the main input request
public
static getMainRequest() : InputRequest|null
Return values
InputRequest|nullgetMainRequest()
Get the main input request
public
static getMainRequest() : HttpRequest
Return values
HttpRequestgetMethod()
Get the method
public
getMethod() : string
Return values
stringgetOption()
Get the option by $key, assuming $default value
public
getOption(string $key[, string|null $short = null ][, mixed|null $default = null ]) : mixed
Parameters
- $key : string
- $short : string|null = null
- $default : mixed|null = null
getParameter()
Get the parameter by $key, assuming $default value
public
getParameter(string $key[, mixed|null $default = null ]) : mixed
Parameters
- $key : string
- $default : mixed|null = null
getParameters()
Get all parameters
public
getParameters() : array<string|int, mixed>
Return values
array<string|int, mixed>getPath()
Get the path
public
getPath() : string
Return values
stringgetPathValue()
Get path value by $key, assuming $default
public
getPathValue(string $key[, mixed $default = null ]) : string|null
Parameters
- $key : string
- $default : mixed = null
Return values
string|null —The path value for $key
getPathValues()
Get path values
public
getPathValues() : array<string|int, mixed>
Return values
array<string|int, mixed>getRoute()
Get the route to this request
public
getRoute() : ControllerRoute|null
Return values
ControllerRoute|nullgetRouteClass()
Get the name of the route class associated to a HttpRequest
public
static getRouteClass() : string
Return values
stringgetRouteName()
Get the route name to this request
public
getRouteName() : string
Return values
stringgetRoutes()
Get all available routes
public
getRoutes() : array<string|int, HttpRoute>
Tags
Return values
array<string|int, HttpRoute>getScheme()
Get the scheme
public
getScheme() : string
Return values
stringgetUrl()
Get the URL used for this request
public
getUrl() : string
Return values
stringhandleCurrentRequest()
Handle the current request as a HttpRequest one This method ends the script
public
static handleCurrentRequest() : void
hasArrayData()
Test if data $key is an array
public
hasArrayData(string $key) : bool
Parameters
- $key : string
Return values
boolhasData()
Test if data contains the $key
public
hasData([string|null $key = null ]) : bool
Parameters
- $key : string|null = null
Return values
boolhasDataKey()
Test if path contains a value and return it as parameter
public
hasDataKey([string|null $path = null ][, string|null &$key = null ]) : bool
Parameters
- $path : string|null = null
-
The path to get the value
- $key : string|null = null
-
The value as output parameter
Return values
boolhasInput()
Test if request has any input
public
hasInput() : bool
Return values
boolhasInputValue()
Test if input $key exists in this request
public
hasInputValue(string $key) : bool
Parameters
- $key : string
Return values
boolhasParameter()
Test if parameter $key exists in this request
public
hasParameter(string $key) : bool
Parameters
- $key : string
Return values
boolhasPathValue()
Check request has path value $key
public
hasPathValue(string $key) : bool
Parameters
- $key : string
Return values
bool —True if it has the $key value in path
isDelete()
Test if this is a DELETE request
public
isDelete() : bool
Return values
boolisGet()
Test if this is a GET request
public
isGet() : bool
Return values
boolisPost()
Test if this is a POST request
public
isPost() : bool
Return values
boolisPostSiteOverLimit()
Test incoming request is over php max post size
public
isPostSiteOverLimit() : bool
Tags
Return values
boolisPut()
Test if this is a PUT request
public
isPut() : bool
Return values
boolmatchPath()
Test path is matching regex
public
matchPath(string $regex, array<string|int, mixed>|null &$matches) : string
Parameters
- $regex : string
- $matches : array<string|int, mixed>|null
Return values
stringprocess()
Process the request by finding a route and processing it
public
process() : OutputResponse
Tags
Return values
OutputResponseprocessRoute()
Process the given route
public
processRoute(ControllerRoute $route, array<string|int, mixed> $values) : OutputResponse
Parameters
- $route : ControllerRoute
- $values : array<string|int, mixed>
Tags
Return values
OutputResponseredirect()
Redirect response to $route
public
redirect(ControllerRoute $route) : RedirectHttpResponse|null
Parameters
- $route : ControllerRoute
Return values
RedirectHttpResponse|null —Should be overridden to be used
setRoute()
Set the route to this request
public
setRoute(ControllerRoute $route, array<string|int, mixed> $values) : InputRequest
Parameters
- $route : ControllerRoute
- $values : array<string|int, mixed>
Return values
InputRequestshowFallbackError()
public
static showFallbackError(Throwable $exception, Throwable|null $responseException) : void
Parameters
- $exception : Throwable
- $responseException : Throwable|null
setContent()
Set the content (input & input type)
protected
setContent(array<string|int, mixed>|string|null $content, string $contentType) : HttpRequest
Parameters
- $content : array<string|int, mixed>|string|null
- $contentType : string
Return values
HttpRequestsetCookies()
Set the cookies
protected
setCookies(array<string|int, mixed> $cookies) : HttpRequest
Parameters
- $cookies : array<string|int, mixed>
Return values
HttpRequestsetDomain()
Set the host domain
protected
setDomain(string $domain) : $this
Parameters
- $domain : string
Return values
$thissetFiles()
Set the uploaded files
protected
setFiles(array<string|int, mixed> $files) : HttpRequest
Parameters
- $files : array<string|int, mixed>
Return values
HttpRequestsetHeaders()
Set the headers
protected
setHeaders(array<string|int, mixed> $headers) : HttpRequest
Parameters
- $headers : array<string|int, mixed>
Return values
HttpRequestsetInput()
Set the input
protected
setInput(array<string|int, mixed>|string|null $input) : InputRequest
Parameters
- $input : array<string|int, mixed>|string|null
Return values
InputRequestsetInputType()
Set the input type
protected
setInputType(string $inputType) : HttpRequest
Parameters
- $inputType : string
Return values
HttpRequestsetMethod()
Set the method
protected
setMethod(string $method) : HttpRequest
Parameters
- $method : string
Return values
HttpRequestsetParameters()
Set the parameters
protected
setParameters(array<string|int, mixed> $parameters) : InputRequest
Parameters
- $parameters : array<string|int, mixed>
Return values
InputRequestsetPath()
Set the path
protected
setPath(string $path) : InputRequest
Parameters
- $path : string
Return values
InputRequestsetScheme()
Set the scheme
protected
setScheme(string $scheme) : HttpRequest
Parameters
- $scheme : string