Request
extends AbstractRequest
in package
HTTP server request class
Tags
Table of Contents
Properties
- $auth : Auth|null
- HTTP auth object
- $body : Body|null
- Body
- $cookie : array<string|int, mixed>
- COOKIE array
- $data : Data|null
- Server request data object
- $env : array<string|int, mixed>
- ENV array
- $headers : array<string|int, mixed>
- Headers
- $server : array<string|int, mixed>
- SERVER array
- $uri : Uri|null
- Request URI object
Methods
- __construct() : mixed
- Constructor
- __get() : mixed
- Magic method to get a value from one of the server/environment variables
- addHeader() : AbstractRequestResponse
- Add a header
- addHeaders() : AbstractRequestResponse
- Add all headers
- create() : Request
- Factory to create a new request object
- createWithBasePath() : Request
- Factory to create a new request object with a base path reference for the request URI
- decodeBodyContent() : Body
- Decode the body
- getAuth() : Auth
- Get the auth object
- getBasePath() : string
- Get the base path
- getBody() : Body
- Get the body
- getBodyContent() : mixed
- Get body content
- getBodyContentLength() : int
- Get body content length
- getCookie() : string|array<string|int, mixed>|null
- Get a value from $_COOKIE, or the whole array
- getData() : Uri
- Get data
- getDelete() : string|array<string|int, mixed>|null
- Get a value from DELETE query data, or the whole array
- getDocumentRoot() : string|null
- Get the document root
- getEnv() : string|array<string|int, mixed>|null
- Get a value from $_ENV, or the whole array
- getFiles() : string|array<string|int, mixed>|null
- Get a value from $_FILES, or the whole array
- getFullHost() : string
- Get host with port
- getFullUriString() : string
- Get the full request URI, including base path
- getHeader() : mixed
- Get a header
- getHeaderAsString() : mixed
- Get a header
- getHeaders() : array<string|int, mixed>
- Get all headers
- getHeadersAsArray() : array<string|int, mixed>
- Get all header values as associative array
- getHeadersAsString() : string
- Get all header values formatted string
- getHeaderValue() : mixed
- Get header value
- getHeaderValueAsString() : string|null
- Get header value as string
- getHost() : string
- Get host (without port)
- getIp() : string
- Get client's IP
- getMethod() : string|null
- Get the method
- getParsedData() : string|array<string|int, mixed>|null
- Get a value from parsed data, or the whole array
- getPatch() : string|array<string|int, mixed>|null
- Get a value from PATCH query data, or the whole array
- getPort() : string|null
- Get the server port
- getPost() : string|array<string|int, mixed>|null
- Get a value from $_POST, or the whole array
- getPut() : string|array<string|int, mixed>|null
- Get a value from PUT query data, or the whole array
- getQuery() : string|array<string|int, mixed>|null
- Get a value from $_GET, or the whole array
- getQueryData() : string|array<string|int, mixed>|null
- Get a value from query data, or the whole array
- getRawData() : string|null
- Get the raw data
- getScheme() : string
- Get scheme
- getSegment() : string|null
- Get a path segment, divided by the forward slash, where $i refers to the array key index, i.e., 0 1 2 /hello/world/page
- getSegments() : array<string|int, mixed>
- Get all path segments
- getServer() : string|array<string|int, mixed>|null
- Get a value from $_SERVER, or the whole array
- getUri() : Uri
- Get URI
- getUriAsString() : string
- Get URI as string
- getUriString() : string
- Get the request URI
- hasAuth() : bool
- Has auth object
- hasBody() : bool
- Has a body
- hasBodyContent() : bool
- Has body content
- hasData() : bool
- Has data
- hasFiles() : bool
- Return whether or not the request has FILES
- hasHeader() : bool
- Has a header
- hasHeaders() : bool
- Determine if there are headers
- hasParsedData() : bool
- Has parsed data
- hasQueryData() : bool
- Has query data
- hasRawData() : bool
- Has raw data
- hasUri() : bool
- Has URI
- isConnect() : bool
- Return whether or not the method is CONNECT
- isDelete() : bool
- Return whether or not the method is DELETE
- isGet() : bool
- Return whether or not the method is GET
- isHead() : bool
- Return whether or not the method is HEAD
- isOptions() : bool
- Return whether or not the method is OPTIONS
- isPatch() : bool
- Return whether or not the method is PATCH
- isPost() : bool
- Return whether or not the method is POST
- isPut() : bool
- Return whether or not the method is PUT
- isSecure() : bool
- Return whether or not the request is secure
- isTrace() : bool
- Return whether or not the method is TRACE
- removeBody() : AbstractRequestResponse
- Remove the body
- removeHeader() : AbstractRequestResponse
- Remove a header
- removeHeaders() : AbstractRequestResponse
- Remove all headers
- setAuth() : Request
- Set the auth object
- setBasePath() : Request
- Set the base path
- setBody() : AbstractRequestResponse
- Set the body
- setHeaders() : AbstractRequestResponse
- Set all headers (clear out any existing headers)
- setUri() : AbstractRequest
- Set URI
Properties
$auth
HTTP auth object
protected
Auth|null
$auth
= null
$body
Body
protected
Body|null
$body
= null
$cookie
COOKIE array
protected
array<string|int, mixed>
$cookie
= []
$data
Server request data object
protected
Data|null
$data
= null
$env
ENV array
protected
array<string|int, mixed>
$env
= []
$headers
Headers
protected
array<string|int, mixed>
$headers
= []
$server
SERVER array
protected
array<string|int, mixed>
$server
= []
$uri
Request URI object
protected
Uri|null
$uri
= null
Methods
__construct()
Constructor
public
__construct([Uri|string|null $uri = null ][, mixed $filters = null ][, mixed $streamToFile = null ]) : mixed
Instantiate the request object
Parameters
- $uri : Uri|string|null = null
- $filters : mixed = null
- $streamToFile : mixed = null
Tags
__get()
Magic method to get a value from one of the server/environment variables
public
__get(string $name) : mixed
Parameters
- $name : string
addHeader()
Add a header
public
addHeader(Header|string|int $header[, string|null $value = null ]) : AbstractRequestResponse
Parameters
- $header : Header|string|int
- $value : string|null = null
Return values
AbstractRequestResponseaddHeaders()
Add all headers
public
addHeaders(array<string|int, mixed> $headers) : AbstractRequestResponse
Parameters
- $headers : array<string|int, mixed>
Return values
AbstractRequestResponsecreate()
Factory to create a new request object
public
static create([Uri|null $uri = null ][, mixed $filters = null ][, mixed $streamToFile = null ]) : Request
Parameters
- $uri : Uri|null = null
- $filters : mixed = null
- $streamToFile : mixed = null
Tags
Return values
RequestcreateWithBasePath()
Factory to create a new request object with a base path reference for the request URI
public
static createWithBasePath(string $basePath[, mixed $filters = null ][, mixed $streamToFile = null ]) : Request
Parameters
- $basePath : string
- $filters : mixed = null
- $streamToFile : mixed = null
Return values
RequestdecodeBodyContent()
Decode the body
public
decodeBodyContent([string|null $body = null ]) : Body
Parameters
- $body : string|null = null
Return values
BodygetAuth()
Get the auth object
public
getAuth() : Auth
Return values
AuthgetBasePath()
Get the base path
public
getBasePath() : string
Return values
stringgetBody()
Get the body
public
getBody() : Body
Return values
BodygetBodyContent()
Get body content
public
getBodyContent() : mixed
getBodyContentLength()
Get body content length
public
getBodyContentLength([bool $mb = false ]) : int
Parameters
- $mb : bool = false
Return values
intgetCookie()
Get a value from $_COOKIE, or the whole array
public
getCookie([string|null $key = null ]) : string|array<string|int, mixed>|null
Parameters
- $key : string|null = null
Return values
string|array<string|int, mixed>|nullgetData()
Get data
public
getData() : Uri
Return values
UrigetDelete()
Get a value from DELETE query data, or the whole array
public
getDelete([string|null $key = null ]) : string|array<string|int, mixed>|null
Parameters
- $key : string|null = null
Return values
string|array<string|int, mixed>|nullgetDocumentRoot()
Get the document root
public
getDocumentRoot() : string|null
Return values
string|nullgetEnv()
Get a value from $_ENV, or the whole array
public
getEnv([string|null $key = null ]) : string|array<string|int, mixed>|null
Parameters
- $key : string|null = null
Return values
string|array<string|int, mixed>|nullgetFiles()
Get a value from $_FILES, or the whole array
public
getFiles([string|null $key = null ]) : string|array<string|int, mixed>|null
Parameters
- $key : string|null = null
Return values
string|array<string|int, mixed>|nullgetFullHost()
Get host with port
public
getFullHost() : string
Return values
stringgetFullUriString()
Get the full request URI, including base path
public
getFullUriString() : string
Return values
stringgetHeader()
Get a header
public
getHeader(string $name) : mixed
Parameters
- $name : string
getHeaderAsString()
Get a header
public
getHeaderAsString(string $name) : mixed
Parameters
- $name : string
getHeaders()
Get all headers
public
getHeaders() : array<string|int, mixed>
Return values
array<string|int, mixed>getHeadersAsArray()
Get all header values as associative array
public
getHeadersAsArray([bool $asStrings = true ]) : array<string|int, mixed>
Parameters
- $asStrings : bool = true
Return values
array<string|int, mixed>getHeadersAsString()
Get all header values formatted string
public
getHeadersAsString([mixed $status = null ][, string $eol = "
" ]) : string
Parameters
- $status : mixed = null
- $eol : string = " "
Return values
stringgetHeaderValue()
Get header value
public
getHeaderValue(string $name[, int $i = 0 ]) : mixed
Parameters
- $name : string
- $i : int = 0
getHeaderValueAsString()
Get header value as string
public
getHeaderValueAsString(string $name[, int $i = 0 ]) : string|null
Parameters
- $name : string
- $i : int = 0
Return values
string|nullgetHost()
Get host (without port)
public
getHost() : string
Return values
stringgetIp()
Get client's IP
public
getIp([bool $proxy = true ]) : string
Parameters
- $proxy : bool = true
Return values
stringgetMethod()
Get the method
public
getMethod() : string|null
Return values
string|nullgetParsedData()
Get a value from parsed data, or the whole array
public
getParsedData([string|null $key = null ]) : string|array<string|int, mixed>|null
Parameters
- $key : string|null = null
Return values
string|array<string|int, mixed>|nullgetPatch()
Get a value from PATCH query data, or the whole array
public
getPatch([string|null $key = null ]) : string|array<string|int, mixed>|null
Parameters
- $key : string|null = null
Return values
string|array<string|int, mixed>|nullgetPort()
Get the server port
public
getPort() : string|null
Return values
string|nullgetPost()
Get a value from $_POST, or the whole array
public
getPost([string|null $key = null ]) : string|array<string|int, mixed>|null
Parameters
- $key : string|null = null
Return values
string|array<string|int, mixed>|nullgetPut()
Get a value from PUT query data, or the whole array
public
getPut([string|null $key = null ]) : string|array<string|int, mixed>|null
Parameters
- $key : string|null = null
Return values
string|array<string|int, mixed>|nullgetQuery()
Get a value from $_GET, or the whole array
public
getQuery([string|null $key = null ]) : string|array<string|int, mixed>|null
Parameters
- $key : string|null = null
Return values
string|array<string|int, mixed>|nullgetQueryData()
Get a value from query data, or the whole array
public
getQueryData([string|null $key = null ]) : string|array<string|int, mixed>|null
Parameters
- $key : string|null = null
Return values
string|array<string|int, mixed>|nullgetRawData()
Get the raw data
public
getRawData() : string|null
Return values
string|nullgetScheme()
Get scheme
public
getScheme() : string
Return values
stringgetSegment()
Get a path segment, divided by the forward slash, where $i refers to the array key index, i.e., 0 1 2 /hello/world/page
public
getSegment(int $i) : string|null
Parameters
- $i : int
Return values
string|nullgetSegments()
Get all path segments
public
getSegments() : array<string|int, mixed>
Return values
array<string|int, mixed>getServer()
Get a value from $_SERVER, or the whole array
public
getServer([string|null $key = null ]) : string|array<string|int, mixed>|null
Parameters
- $key : string|null = null
Return values
string|array<string|int, mixed>|nullgetUri()
Get URI
public
getUri() : Uri
Return values
UrigetUriAsString()
Get URI as string
public
getUriAsString() : string
Return values
stringgetUriString()
Get the request URI
public
getUriString() : string
Return values
stringhasAuth()
Has auth object
public
hasAuth() : bool
Return values
boolhasBody()
Has a body
public
hasBody() : bool
Return values
boolhasBodyContent()
Has body content
public
hasBodyContent() : bool
Return values
boolhasData()
Has data
public
hasData() : bool
Return values
boolhasFiles()
Return whether or not the request has FILES
public
hasFiles() : bool
Return values
boolhasHeader()
Has a header
public
hasHeader(string $name) : bool
Parameters
- $name : string
Return values
boolhasHeaders()
Determine if there are headers
public
hasHeaders() : bool
Return values
boolhasParsedData()
Has parsed data
public
hasParsedData() : bool
Return values
boolhasQueryData()
Has query data
public
hasQueryData() : bool
Return values
boolhasRawData()
Has raw data
public
hasRawData() : bool
Return values
boolhasUri()
Has URI
public
hasUri() : bool
Return values
boolisConnect()
Return whether or not the method is CONNECT
public
isConnect() : bool
Return values
boolisDelete()
Return whether or not the method is DELETE
public
isDelete() : bool
Return values
boolisGet()
Return whether or not the method is GET
public
isGet() : bool
Return values
boolisHead()
Return whether or not the method is HEAD
public
isHead() : bool
Return values
boolisOptions()
Return whether or not the method is OPTIONS
public
isOptions() : bool
Return values
boolisPatch()
Return whether or not the method is PATCH
public
isPatch() : bool
Return values
boolisPost()
Return whether or not the method is POST
public
isPost() : bool
Return values
boolisPut()
Return whether or not the method is PUT
public
isPut() : bool
Return values
boolisSecure()
Return whether or not the request is secure
public
isSecure() : bool
Return values
boolisTrace()
Return whether or not the method is TRACE
public
isTrace() : bool
Return values
boolremoveBody()
Remove the body
public
removeBody() : AbstractRequestResponse
Return values
AbstractRequestResponseremoveHeader()
Remove a header
public
removeHeader(string $name) : AbstractRequestResponse
Parameters
- $name : string
Return values
AbstractRequestResponseremoveHeaders()
Remove all headers
public
removeHeaders() : AbstractRequestResponse
Return values
AbstractRequestResponsesetAuth()
Set the auth object
public
setAuth(Auth $auth) : Request
Parameters
- $auth : Auth
Return values
RequestsetBasePath()
Set the base path
public
setBasePath([string|null $path = null ]) : Request
Parameters
- $path : string|null = null
Return values
RequestsetBody()
Set the body
public
setBody(string|Body $body) : AbstractRequestResponse
Parameters
- $body : string|Body
Return values
AbstractRequestResponsesetHeaders()
Set all headers (clear out any existing headers)
public
setHeaders(array<string|int, mixed> $headers) : AbstractRequestResponse
Parameters
- $headers : array<string|int, mixed>
Return values
AbstractRequestResponsesetUri()
Set URI
public
setUri(Uri|string $uri) : AbstractRequest
Parameters
- $uri : Uri|string