Parameters

Return Value

Exceptions

at line 667

static public string
normalizeQueryString(string $qs)

It builds a normalized query string, where keys/value pairs are alphabetized,
have consistent escaping and unneeded delimiters are removed.

Parameters

string

$qs

Query string

Return Value

string

A normalized query string for the Request

at line 711

static public
enableHttpMethodParameterOverride()

Enables support for the _method request parameter to determine the intended HTTP method.

Be warned that enabling this feature might lead to CSRF issues in your code.
Check that you are using CSRF tokens when required.
If the HTTP method parameter override is enabled, an html-form with method "POST" can be altered
and used to send a "PUT" or "DELETE" request via the _method request parameter.
If these methods are not protected against CSRF, this presents a possible vulnerability.

The HTTP method can only be overridden when the real HTTP method is POST.

Return Value

at line 771

Return Value

at line 784

public bool
hasPreviousSession()

Whether the request contains a Session which was started in one of the previous requests.

Return Value

bool

at line 801

public bool
hasSession()

Whether the request contains a Session object.

This method does not give any information about the state of the session object,
like whether the session is started or not. It is just a way to check if this Request
is associated with a Session instance.

Return Value

bool

true when the Request contains a Session object, false otherwise

at line 813

Parameters

at line 831

public array
getClientIps()

Returns the client IP addresses.

In the returned array the most trusted IP address is first, and the
least trusted one last. The "real" client IP address is the last one,
but this is also the least trusted one. Trusted proxies are stripped.

Use this method carefully; you should use getClientIp() instead.

Return Value

array

The client IP addresses

See also

getClientIp()

at line 886

public string
getClientIp()

Returns the client IP address.

This method can read the client IP address from the "X-Forwarded-For" header
when trusted proxies were set via "setTrustedProxies()". The "X-Forwarded-For"
header value is a comma+space separated list of IP addresses, the left-most
being the original client, and each successive proxy that passed the request
adding the IP address where it received the request from.

If your reverse proxy uses a different header name than "X-Forwarded-For",
("Client-Ip" for instance), configure it via "setTrustedHeaderName()" with
the "client-ip" key.

Return Value

string

The client IP address

See also

getClientIps()

http://en.wikipedia.org/wiki/X-Forwarded-For

at line 900

public string
getScriptName()

Returns current script name.

Return Value

string

at line 921

public string
getPathInfo()

Returns the path being requested relative to the executed script.

The path info always starts with a /.

Suppose this request is instantiated from /mysite on localhost:

http://localhost/mysite returns an empty string

http://localhost/mysite/about returns '/about'

http://localhost/mysite/enco%20ded returns '/enco%20ded'

http://localhost/mysite/about?var=1 returns '/about'

Return Value

string

The raw path (i.e. not urldecoded)

at line 944

public string
getBasePath()

Returns the root path from which this request is executed.

Suppose that an index.php file instantiates this request object:

http://localhost/index.php returns an empty string

http://localhost/index.php/page returns an empty string

http://localhost/web/index.php returns '/web'

http://localhost/we%20b/index.php returns '/we%20b'

Return Value

string

The raw path (i.e. not urldecoded)

at line 965

public string
getBaseUrl()

Returns the root URL from which this request is executed.

The base URL never ends with a /.

This is similar to getBasePath(), except that it also includes the
script filename (e.g. index.php) if one exists.

Return Value

string

The raw URL (i.e. not urldecoded)

at line 981

public string
getScheme()

Gets the request's scheme.

Return Value

string

at line 1001

public string
getPort()

Returns the port on which the request is made.

This method can read the client port from the "X-Forwarded-Port" header
when trusted proxies were set via "setTrustedProxies()".

The "X-Forwarded-Port" header must contain the client port.

If your reverse proxy uses a different header name than "X-Forwarded-Port",
configure it via "setTrustedHeaderName()" with the "client-port" key.

Return Value

string

at line 1035

public string|null
getUser()

Returns the user.

Return Value

string|null

at line 1045

public string|null
getPassword()

Returns the password.

Return Value

string|null

at line 1055

public string
getUserInfo()

Gets the user info.

Return Value

string

A user name and, optionally, scheme-specific information about how to gain authorization to access the server

at line 1076

public string
getHttpHost()

Returns the HTTP host being requested.

The port name will be appended to the host if it's non-standard.

Return Value

string

at line 1095

public string
getRequestUri()

Returns the requested URI (path and query string).

Return Value

string

The raw URI (i.e. not URI decoded)

at line 1112

public string
getSchemeAndHttpHost()

Gets the scheme and HTTP host.

If the URL was called with basic authentication, the user
and the password are not added to the generated string.

Return Value

string

The scheme and HTTP host

at line 1126

public string
getUri()

Generates a normalized URI (URL) for the Request.

Return Value

string

A normalized URI (URL) for the Request

See also

getQueryString()

at line 1144

public string
getUriForPath(string $path)

Generates a normalized URI for the given path.

Parameters

string

$path

A path to use instead of the current one

Return Value

string

The normalized URI for the path

at line 1168

public string
getRelativeUriForPath(string $path)

Returns the path as relative reference from the current Request path.

Only the URIs path component (no schema, host etc.) is relevant and must be given.
Both paths must be absolute and not contain relative parts.
Relative URLs from one resource to another are useful when generating self-contained downloadable document archives.
Furthermore, they can be used to reduce the link size in documents.