class Request

Traits

Methods

static array
getAcceptedLanguages()

Gets the languages accepted by the browser, by order of priority.

static string
getRemoteAddress()

Gets remote IP address.

static bool
isFromLocalHost()

No description

static string
getServerURL()

No description

from  WithURL
static int
getPort()

No description

from  WithURL
static string
getServerName()

No description

from  WithURL
static string
getScheme()

No description

from  WithURL
static bool
isHTTPS()

No description

from  WithURL
static URL
createLocalURL(string $query = "", int $encodeMode = URL::ENCODE_RFC3986_SLASH_EXCEPTED)

Create a URL object, using the current request server URL for protocol and domain name.

from  WithURL
withBaseUrl(string $url)

No description

withSiteUrl(string $url)

No description

string
buildUrl(string ...$parts)

Gets the URL matching the specified resource.

string
getCurrentUrl()

Gets $_SERVER["PATH_INFO"] or computes the equivalent if not defined.

array
getCurrentUrlFragments()

Gets an array of url fragments to be processed by controller

Details

static array getAcceptedLanguages()

Gets the languages accepted by the browser, by order of priority.

This will read the HTTP_ACCEPT_LANGUAGE variable sent by the browser in the HTTP request.

Return Value

array

each item a language accepted by browser

in WithRemoteAddress at line 21
static string getRemoteAddress()

Gets remote IP address.

This is intended as a drop-in replacement for $_SERVER['REMOTE_ADDR'], which takes in consideration proxy values, blindly trusted.

This method should is only for environment where headers are controlled, like nginx + phpfpm, where HTTP headers are reserved for the server information, and where the headers sent by the web server to nginx are checked or populated by nginx itself.

Return Value

string

the remote address

in WithRemoteAddress at line 25
static bool isFromLocalHost()

No description

Return Value

bool

in WithURL at line 14
static string getServerURL()

No description

Return Value

string

in WithURL at line 37
static int getPort()

No description

Return Value

int

in WithURL at line 41
static string getServerName()

No description

Return Value

string

in WithURL at line 45
static string getScheme()

No description

Return Value

string

in WithURL at line 57
static bool isHTTPS()

No description

Return Value

bool

in WithURL at line 95
static URL createLocalURL(string $query = "", int $encodeMode = URL::ENCODE_RFC3986_SLASH_EXCEPTED)

Create a URL object, using the current request server URL for protocol and domain name.

Parameters

string $query

The query part of the URL [facultative]

int $encodeMode

Encoding to use for the query [facultative]

Return Value

URL

in WithLocalURL at line 25
WithLocalURL withBaseUrl(string $url)

No description

Parameters

string $url

Return Value

WithLocalURL

in WithLocalURL at line 31
WithLocalURL withSiteUrl(string $url)

No description

Parameters

string $url

Return Value

WithLocalURL

in WithLocalURL at line 57
string buildUrl(string ...$parts)

Gets the URL matching the specified resource.

Example:

$ship = new Ship();
$ship->id = "S00001";

$request = new Request();
$url = $request->buildUrl("ship", $ship->id);
echo $url; // This should print "/ship/S00001"

Parameters

string ...$parts

The URL parts

Return Value

string

the URL matching the specified resource

in WithLocalURL at line 97
string getCurrentUrl()

Gets $_SERVER["PATH_INFO"] or computes the equivalent if not defined.

This function allows the entry point controllers to get the current URL consistently, for any redirection configuration.

So with /foo/bar, /index.php/foo/bar, /zed/index.php/foo/bar or /zed/foo/bar Request::getCurrentUrl() will return /foo/bar each time.

Return Value

string

the relevant URL part

in WithLocalURL at line 154
array getCurrentUrlFragments()

Gets an array of url fragments to be processed by controller

Return Value

array

an array of string, one for each URL fragment

See also

\Keruald\OmniTools\HTTP\Requests\self::getCurrentUrl() This method is used by the controllers' entry points to know the URL and call relevant subcontrollers.