Documentation

Request extends AbstractRequest
in package

HTTP server request class

Tags
category

Pop

author

Nick Sagona, III dev@nolainteractive.com

copyright

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

license

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

version
5.2.0

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
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

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 = []

$server

SERVER array

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

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
throws
Exception|Exception

__get()

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

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

create()

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
throws
Exception|Exception
Return values
Request

decodeBodyContent()

Decode the body

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

getBasePath()

Get the base path

public getBasePath() : string
Return values
string

getBodyContentLength()

Get body content length

public getBodyContentLength([bool $mb = false ]) : int
Parameters
$mb : bool = false
Return values
int

getCookie()

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>|null

getDelete()

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>|null

getDocumentRoot()

Get the document root

public getDocumentRoot() : string|null
Return values
string|null

getEnv()

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>|null

getFiles()

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>|null

getFullHost()

Get host with port

public getFullHost() : string
Return values
string

getFullUriString()

Get the full request URI, including base path

public getFullUriString() : string
Return values
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
string

getHeaderValue()

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|null

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|null
Return values
string|null

getParsedData()

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>|null

getPatch()

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>|null

getPort()

Get the server port

public getPort() : string|null
Return values
string|null

getPost()

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>|null

getPut()

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>|null

getQuery()

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>|null

getQueryData()

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>|null

getRawData()

Get the raw data

public getRawData() : string|null
Return values
string|null

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

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

getUriAsString()

Get URI as string

public getUriAsString() : string
Return values
string

getUriString()

Get the request URI

public getUriString() : string
Return values
string

hasAuth()

Has auth object

public hasAuth() : bool
Return values
bool

hasData()

Has data

public hasData() : bool
Return values
bool

hasFiles()

Return whether or not the request has FILES

public hasFiles() : bool
Return values
bool

hasHeader()

Has a header

public hasHeader(string $name) : bool
Parameters
$name : string
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|null $path = null ]) : Request
Parameters
$path : string|null = null
Return values
Request

        
On this page

Search results