Documentation

RequestTrait

Request Trait

Additional methods to make a PSR-7 Request class compliant with the framework's own RequestInterface.

Tags
see
https://github.com/php-fig/http-message/blob/master/src/RequestInterface.php

Table of Contents

$globals  : array<string|int, mixed>
Stores values we've retrieved from PHP globals.
$ipAddress  : string
IP address of the current user.
fetchGlobal()  : mixed
Fetches one or more items from a global, like cookies, get, post, etc.
getEnv()  : mixed
Fetch an item from the $_ENV array.
getIPAddress()  : string
Gets the user's IP address.
getServer()  : mixed
Fetch an item from the $_SERVER array.
setGlobal()  : $this
Allows manually setting the value of PHP global, like $_GET, $_POST, etc.
populateGlobals()  : mixed
Saves a copy of the current state of one of several PHP globals so we can retrieve them later.

Properties

$globals

Stores values we've retrieved from PHP globals.

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

$ipAddress

IP address of the current user.

protected string $ipAddress = ''
Tags
deprecated

Will become private in a future release

Methods

fetchGlobal()

Fetches one or more items from a global, like cookies, get, post, etc.

public fetchGlobal(string $method[, string|array<string|int, mixed>|null $index = null ][, int|null $filter = null ][, array<string|int, mixed>|int|null $flags = null ]) : mixed

Can optionally filter the input when you retrieve it by passing in a filter.

If $type is an array, it must conform to the input allowed by the filter_input_array method.

http://php.net/manual/en/filter.filters.sanitize.php

Parameters
$method : string

Input filter constant

$index : string|array<string|int, mixed>|null = null
$filter : int|null = null

Filter constant

$flags : array<string|int, mixed>|int|null = null

Options

Return values
mixed

getEnv()

Fetch an item from the $_ENV array.

public getEnv([null $index = null ][, null $filter = null ][, null $flags = null ]) : mixed
Parameters
$index : null = null

Index for item to be fetched from $_ENV

$filter : null = null

A filter name to be applied

$flags : null = null
Return values
mixed

getIPAddress()

Gets the user's IP address.

public getIPAddress() : string
Return values
string

IP address

getServer()

Fetch an item from the $_SERVER array.

public getServer([string|array<string|int, mixed>|null $index = null ][, int|null $filter = null ][, null $flags = null ]) : mixed
Parameters
$index : string|array<string|int, mixed>|null = null

Index for item to be fetched from $_SERVER

$filter : int|null = null

A filter name to be applied

$flags : null = null
Return values
mixed

setGlobal()

Allows manually setting the value of PHP global, like $_GET, $_POST, etc.

public setGlobal(string $method, mixed $value) : $this
Parameters
$method : string
$value : mixed
Return values
$this

populateGlobals()

Saves a copy of the current state of one of several PHP globals so we can retrieve them later.

protected populateGlobals(string $method) : mixed
Parameters
$method : string
Return values
mixed

Search results