Documentation

Request extends AbstractRequest
in package

HTTP server request class

Tags
category

Pop

author

Nick Sagona, III dev@nolainteractive.com

copyright

Copyright (c) 2009-2021 NOLA Interactive, LLC. (http://www.nolainteractive.com)

license

http://www.popphp.org/license New BSD License

version
4.1.0

Table of Contents

$body  : Body
Body
$cookie  : array<string|int, mixed>
COOKIE array
$env  : array<string|int, mixed>
ENV array
$filters  : array<string|int, mixed>
Form filters
$headers  : array<string|int, mixed>
Headers
$requestData  : Data
Request data object
$requestUri  : Uri
Request URI object
$server  : array<string|int, mixed>
SERVER array
__construct()  : mixed
Constructor
__get()  : mixed
Magic method to get a value from one of the server/environment variables
addFilter()  : FilterableTrait
Add filter
addFilters()  : FilterableTrait
Add filters
addHeader()  : AbstractHttp
Add a header
addHeaders()  : AbstractHttp
Add all headers
clearFilters()  : FilterableTrait
Clear filters
decodeBodyContent()  : Body
Decode the body
filter()  : array<string|int, mixed>
Filter values
filterAll()  : array<string|int, mixed>
Filter all values, ignoring excludes
getBasePath()  : string
Get the base path
getBody()  : Body
Get the body
getBodyContent()  : mixed
Get body content
getCookie()  : string|array<string|int, mixed>
Get a value from $_COOKIE, or the whole array
getDelete()  : string|array<string|int, mixed>
Get a value from DELETE query data, or the whole array
getDocumentRoot()  : string
Get the document root
getEnv()  : string|array<string|int, mixed>
Get a value from $_ENV, or the whole array
getFiles()  : string|array<string|int, mixed>
Get a value from $_FILES, or the whole array
getFilters()  : array<string|int, mixed>
Get filters
getFullHost()  : string
Get host with port
getFullRequestUri()  : string
Get the full request URI, including base path
getHeader()  : 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
getHost()  : string
Get host without port)
getIp()  : string
Get client's IP
getMethod()  : string
Get the method
getParsedData()  : string|array<string|int, mixed>
Get a value from parsed data, or the whole array
getPatch()  : string|array<string|int, mixed>
Get a value from PATCH query data, or the whole array
getPort()  : string
Get the server port
getPost()  : string|array<string|int, mixed>
Get a value from $_POST, or the whole array
getPut()  : string|array<string|int, mixed>
Get a value from PUT query data, or the whole array
getQuery()  : string|array<string|int, mixed>
Get a value from $_GET, or the whole array
getQueryData()  : string|array<string|int, mixed>
Get a value from query data, or the whole array
getRawData()  : string
Get the raw data
getRequestDataObject()  : Data
Get request data object
getRequestUri()  : string
Get the request URI
getRequestUriObject()  : Uri
Get request URI object
getScheme()  : string
Get scheme
getSegment()  : string
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>
Get a value from $_SERVER, or the whole array
hasBody()  : bool
Has a body
hasBodyContent()  : bool
Has body content
hasFiles()  : bool
Return whether or not the request has FILES
hasFilters()  : bool
Has filters
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
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()  : AbstractHttp
Remove the body
removeHeader()  : AbstractHttp
Remove a header
removeHeaders()  : AbstractHttp
Remove all headers
setBasePath()  : Request
Set the base path
setBody()  : AbstractHttp
Set the body

Properties

COOKIE array

protected array<string|int, mixed> $cookie = []

$env

ENV array

protected array<string|int, mixed> $env = []

$filters

Form filters

protected array<string|int, mixed> $filters = []

$headers

Headers

protected array<string|int, mixed> $headers = []

$requestData

Request data object

protected Data $requestData = null

$requestUri

Request URI object

protected Uri $requestUri = null

$server

SERVER array

protected array<string|int, mixed> $server = []

Methods

__construct()

Constructor

public __construct([string $uri = null ][, string $basePath = null ][, mixed $filters = null ][, mixed $streamToFile = null ]) : mixed

Instantiate the request object

Parameters
$uri : string = null
$basePath : string = null
$filters : mixed = null
$streamToFile : mixed = null
Return values
mixed

__get()

Magic method to get a value from one of the server/environment variables

public __get(string $name) : mixed
Parameters
$name : string
Return values
mixed

decodeBodyContent()

Decode the body

public decodeBodyContent([string $body = null ]) : Body
Parameters
$body : string = null
Return values
Body

filter()

Filter values

public abstract filter(mixed $values) : array<string|int, mixed>
Parameters
$values : mixed
Return values
array<string|int, mixed>

filterAll()

Filter all values, ignoring excludes

public filterAll(array<string|int, mixed> $values) : array<string|int, mixed>
Parameters
$values : array<string|int, mixed>
Return values
array<string|int, mixed>

getBasePath()

Get the base path

public getBasePath() : string
Return values
string

getBodyContent()

Get body content

public getBodyContent() : mixed
Return values
mixed

getCookie()

Get a value from $_COOKIE, or the whole array

public getCookie([string $key = null ]) : string|array<string|int, mixed>
Parameters
$key : string = null
Return values
string|array<string|int, mixed>

getDelete()

Get a value from DELETE query data, or the whole array

public getDelete([string $key = null ]) : string|array<string|int, mixed>
Parameters
$key : string = null
Return values
string|array<string|int, mixed>

getDocumentRoot()

Get the document root

public getDocumentRoot() : string
Return values
string

getEnv()

Get a value from $_ENV, or the whole array

public getEnv([string $key = null ]) : string|array<string|int, mixed>
Parameters
$key : string = null
Return values
string|array<string|int, mixed>

getFiles()

Get a value from $_FILES, or the whole array

public getFiles([string $key = null ]) : string|array<string|int, mixed>
Parameters
$key : string = null
Return values
string|array<string|int, mixed>

getFilters()

Get filters

public getFilters() : array<string|int, mixed>
Return values
array<string|int, mixed>

getFullHost()

Get host with port

public getFullHost() : string
Return values
string

getFullRequestUri()

Get the full request URI, including base path

public getFullRequestUri() : string
Return values
string

getHeader()

Get a header

public getHeader(string $name) : mixed
Parameters
$name : string
Return values
mixed

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() : array<string|int, mixed>
Return values
array<string|int, mixed>

getHeadersAsString()

Get all header values formatted string

public getHeadersAsString([string $status = null ][, string $eol = " " ]) : string
Parameters
$status : string = null
$eol : string = " "
Return values
string

getHeaderValue()

Get header value

public getHeaderValue(string $name) : mixed
Parameters
$name : string
Return values
mixed

getHost()

Get host without port)

public getHost() : string
Return values
string

getIp()

Get client's IP

public getIp([bool $proxy = true ]) : string
Parameters
$proxy : bool = true
Return values
string

getMethod()

Get the method

public getMethod() : string
Return values
string

getParsedData()

Get a value from parsed data, or the whole array

public getParsedData([string $key = null ]) : string|array<string|int, mixed>
Parameters
$key : string = null
Return values
string|array<string|int, mixed>

getPatch()

Get a value from PATCH query data, or the whole array

public getPatch([string $key = null ]) : string|array<string|int, mixed>
Parameters
$key : string = null
Return values
string|array<string|int, mixed>

getPort()

Get the server port

public getPort() : string
Return values
string

getPost()

Get a value from $_POST, or the whole array

public getPost([string $key = null ]) : string|array<string|int, mixed>
Parameters
$key : string = null
Return values
string|array<string|int, mixed>

getPut()

Get a value from PUT query data, or the whole array

public getPut([string $key = null ]) : string|array<string|int, mixed>
Parameters
$key : string = null
Return values
string|array<string|int, mixed>

getQuery()

Get a value from $_GET, or the whole array

public getQuery([string $key = null ]) : string|array<string|int, mixed>
Parameters
$key : string = null
Return values
string|array<string|int, mixed>

getQueryData()

Get a value from query data, or the whole array

public getQueryData([string $key = null ]) : string|array<string|int, mixed>
Parameters
$key : string = null
Return values
string|array<string|int, mixed>

getRawData()

Get the raw data

public getRawData() : string
Return values
string

getRequestDataObject()

Get request data object

public getRequestDataObject() : Data
Return values
Data

getRequestUri()

Get the request URI

public getRequestUri() : string
Return values
string

getRequestUriObject()

Get request URI object

public getRequestUriObject() : Uri
Return values
Uri

getScheme()

Get scheme

public getScheme() : string
Return values
string

getSegment()

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
Parameters
$i : int
Return values
string

getSegments()

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 $key = null ]) : string|array<string|int, mixed>
Parameters
$key : string = null
Return values
string|array<string|int, mixed>

hasBody()

Has a body

public hasBody() : bool
Return values
bool

hasBodyContent()

Has body content

public hasBodyContent() : bool
Return values
bool

hasFiles()

Return whether or not the request has FILES

public hasFiles() : bool
Return values
bool

hasFilters()

Has filters

public hasFilters() : bool
Return values
bool

hasHeader()

Has a header

public hasHeader(string $name) : bool
Parameters
$name : string
Return values
bool

hasHeaders()

Determine if there are headers

public hasHeaders() : bool
Return values
bool

hasParsedData()

Has parsed data

public hasParsedData() : bool
Return values
bool

hasQueryData()

Has query data

public hasQueryData() : bool
Return values
bool

hasRawData()

Has raw data

public hasRawData() : bool
Return values
bool

isConnect()

Return whether or not the method is CONNECT

public isConnect() : bool
Return values
bool

isDelete()

Return whether or not the method is DELETE

public isDelete() : bool
Return values
bool

isGet()

Return whether or not the method is GET

public isGet() : bool
Return values
bool

isHead()

Return whether or not the method is HEAD

public isHead() : bool
Return values
bool

isOptions()

Return whether or not the method is OPTIONS

public isOptions() : bool
Return values
bool

isPatch()

Return whether or not the method is PATCH

public isPatch() : bool
Return values
bool

isPost()

Return whether or not the method is POST

public isPost() : bool
Return values
bool

isPut()

Return whether or not the method is PUT

public isPut() : bool
Return values
bool

isSecure()

Return whether or not the request is secure

public isSecure() : bool
Return values
bool

isTrace()

Return whether or not the method is TRACE

public isTrace() : bool
Return values
bool

setBasePath()

Set the base path

public setBasePath([string $path = null ]) : Request
Parameters
$path : string = null
Return values
Request

Search results