NormalizedParams

This class provides normalized server parameters in HTTP request context.

It normalizes reverse proxy scenarios and various other web server specific differences of the native PSR-7 request object parameters (->getServerParams() / $GLOBALS['_SERVER']).

An instance of this class is available as PSR-7 ServerRequestInterface attribute: $normalizedParams = $request->getAttribute('normalizedParams')

This class substitutes the old GeneralUtility::getIndpEnv() method.

Table of Contents

Properties

$documentRoot  : string
Absolute server path to web document root without trailing slash
$httpAcceptEncoding  : string
HTTP_ACCEPT_ENCODING Will be deprecated later, use $request->getServerParams()['HTTP_ACCEPT_ENCODING'] instead
$httpAcceptLanguage  : string
HTTP_ACCEPT_LANGUAGE Will be deprecated later, use $request->getServerParams()['HTTP_ACCEPT_LANGUAGE'] instead
$httpHost  : string
Sanitized HTTP_HOST value
$httpReferer  : string
HTTP_REFERER Will be deprecated later, use $request->getServerParams()['HTTP_REFERER'] instead
$httpUserAgent  : string
HTTP_USER_AGENT Will be deprecated later, use $request->getServerParams()['HTTP_USER_AGENT'] instead
$isBehindReverseProxy  : bool
True if request via a reverse proxy is detected
$isHttps  : bool
$pathInfo  : string
Entry script path of URI, without domain and without query parameters, with leading / This is often not set at all.
$queryString  : string
QUERY_STRING Will be deprecated later, use $request->getServerParams()['QUERY_STRING'] instead
$remoteAddress  : string
IPv4 or IPv6 address of remote client with resolved proxy setup
$remoteHost  : string
REMOTE_HOST Resolved host name of REMOTE_ADDR if configured in web server Will be deprecated later, use $request->getServerParams()['REMOTE_HOST'] instead
$requestDir  : string
Full Uri with path, but without script name and query parts
$requestHost  : string
Sanitized HTTP_HOST with protocol
$requestHostOnly  : string
Host / domain part of HTTP_HOST, no port, no protocol
$requestPort  : int
Port of HTTP_HOST if given
$requestScript  : string
REQUEST URI with scheme, host, port and path, but *without* query part
$requestUri  : string
REQUEST URI without domain and scheme, with trailing slash
$requestUrl  : string
REQUEST URI with scheme, host, port, path and query
$scriptFilename  : string
Absolute server path to entry script on server filesystem
$scriptName  : string
Entry script path of URI, without domain and without query parameters, with leading /
$sitePath  : string
Path part to frontend, no domain, no protocol
$siteScript  : string
Path to script, without sub path if TYPO3 is running in sub directory, without trailing slash
$siteUrl  : string
Website frontend URL.

Methods

__construct()  : mixed
Constructor calculates all values by incoming variables.
createFromRequest()  : static
Factory method for creating normalized params from a PSR-7 server request object
createFromServerParams()  : static
Factory method, to allow TYPO3 to handle configuration options directly.
getDocumentRoot()  : string
getHttpAcceptEncoding()  : string
Will be deprecated later, use $request->getServerParams()['HTTP_ACCEPT_ENCODING'] instead
getHttpAcceptLanguage()  : string
Will be deprecated later, use $request->getServerParams()['HTTP_ACCEPT_LANGUAGE'] instead
getHttpHost()  : string
getHttpReferer()  : string
Will be deprecated later, use $request->getServerParams()['HTTP_REFERER'] instead
getHttpUserAgent()  : string
Will be deprecated later, use $request->getServerParams()['HTTP_USER_AGENT'] instead
getPathInfo()  : string
Will be deprecated later, use getScriptName() as reliable solution instead
getQueryString()  : string
Will be deprecated later, use $request->getServerParams()['QUERY_STRING'] instead
getRemoteAddress()  : string
getRemoteHost()  : string
Will be deprecated later, use $request->getServerParams()['REMOTE_HOST'] instead
getRequestDir()  : string
getRequestHost()  : string
getRequestHostOnly()  : string
getRequestPort()  : int
getRequestScript()  : string
getRequestUri()  : string
getRequestUrl()  : string
getScriptFilename()  : string
getScriptName()  : string
getSitePath()  : string
getSiteScript()  : string
getSiteUrl()  : string
isBehindReverseProxy()  : bool
isHttps()  : bool
determineDocumentRoot()  : string
Calculate absolute path to web document root
determineHttpHost()  : string
Normalize HTTP_HOST by taking proxy configuration into account.
determineHttps()  : bool
Determine if the client called via HTTPS. Takes proxy ssl terminator configurations into account.
determineIsBehindReverseProxy()  : bool
Check if a configured reverse proxy setup is detected.
determineRemoteAddress()  : string
Determine clients REMOTE_ADDR, even if there is a reverse proxy in between.
determineRequestHostOnly()  : string
HTTP_HOST without port
determineRequestPort()  : int
Requested port if given
determineRequestUri()  : string
Determine REQUEST_URI, taking proxy configuration and various web server specifics into account.
determineScriptName()  : string
Determine script name and path
determineSitePath()  : string
Determine site path
determineSiteScript()  : string
Determine site script
determineSiteUrl()  : string
Determine frontend url

Properties

$documentRoot

Absolute server path to web document root without trailing slash

protected string $documentRoot = ''
  • /var/www

$httpAcceptEncoding

HTTP_ACCEPT_ENCODING Will be deprecated later, use $request->getServerParams()['HTTP_ACCEPT_ENCODING'] instead

protected string $httpAcceptEncoding = ''
  • gzip, deflate

$httpAcceptLanguage

HTTP_ACCEPT_LANGUAGE Will be deprecated later, use $request->getServerParams()['HTTP_ACCEPT_LANGUAGE'] instead

protected string $httpAcceptLanguage = ''
  • de-DE,de;q=0.9,en-US;q=0.8,en;q=0.7

$httpHost

Sanitized HTTP_HOST value

protected string $httpHost = ''

host[:port]

  • www.domain.com
  • www.domain.com:443
  • 192.168.1.42:80

$httpReferer

HTTP_REFERER Will be deprecated later, use $request->getServerParams()['HTTP_REFERER'] instead

protected string $httpReferer = ''

scheme://host[:[port]][path]

  • https://www.domain.com/typo3/module/web/layout?id=42

$httpUserAgent

HTTP_USER_AGENT Will be deprecated later, use $request->getServerParams()['HTTP_USER_AGENT'] instead

protected string $httpUserAgent = ''
  • Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/64.0.3282.140 Safari/537.36

$isBehindReverseProxy

True if request via a reverse proxy is detected

protected bool $isBehindReverseProxy = false

$isHttps

protected bool $isHttps = false

True if request has been done via HTTPS

$pathInfo

Entry script path of URI, without domain and without query parameters, with leading / This is often not set at all.

protected string $pathInfo = ''

Will be deprecated later, use $scriptName instead as more reliable solution.

[path_script]

$queryString

QUERY_STRING Will be deprecated later, use $request->getServerParams()['QUERY_STRING'] instead

protected string $queryString = ''

[query]

  • id=42&foo=bar

$remoteAddress

IPv4 or IPv6 address of remote client with resolved proxy setup

protected string $remoteAddress = ''

$remoteHost

REMOTE_HOST Resolved host name of REMOTE_ADDR if configured in web server Will be deprecated later, use $request->getServerParams()['REMOTE_HOST'] instead

protected string $remoteHost = ''
  • www.clientDomain.com

$requestDir

Full Uri with path, but without script name and query parts

protected string $requestDir = ''

scheme://host[:[port]][path_dir]

  • http://www.domain.com/
  • http://www.domain.com/typo3/

$requestHost

Sanitized HTTP_HOST with protocol

protected string $requestHost = ''

scheme://host[:port]

  • https://www.domain.com

$requestHostOnly

Host / domain part of HTTP_HOST, no port, no protocol

protected string $requestHostOnly = ''
  • www.domain.com
  • 192.168.1.42

$requestPort

Port of HTTP_HOST if given

protected int $requestPort = 0

$requestScript

REQUEST URI with scheme, host, port and path, but *without* query part

protected string $requestScript = ''

scheme://host[:[port]][path_script]

  • http://www.domain.com/index.php
  • http://www.domain.com/typo3/index.php

$requestUri

REQUEST URI without domain and scheme, with trailing slash

protected string $requestUri = ''

[path][?[query]]

  • /some/path?p1=parameter1&p2[key]=value
  • /typo3/some/path?p1=parameter1&p2[key]=value

$requestUrl

REQUEST URI with scheme, host, port, path and query

protected string $requestUrl = ''

scheme://host[:[port]][path][?[query]]

  • http://www.domain.com/some/path?p1=parameter1&p2[key]=value
  • http://www.domain.com/typo3/some/path?id=42

$scriptFilename

Absolute server path to entry script on server filesystem

protected string $scriptFilename = ''
  • /var/www/index.php
  • /var/www/typo3/index.php

$scriptName

Entry script path of URI, without domain and without query parameters, with leading /

protected string $scriptName = ''

[path_script]

  • /index.php
  • /typo3/index.php

$sitePath

Path part to frontend, no domain, no protocol

protected string $sitePath = ''
  • /
  • /some/sub/dir/

$siteScript

Path to script, without sub path if TYPO3 is running in sub directory, without trailing slash

protected string $siteScript = ''
  • index.php?id=42
  • /some/path?id=42
  • typo3/some/path?id=411

$siteUrl

Website frontend URL.

protected string $siteUrl = ''

Note this is note "safe" if called from Backend since sys_domain and other factors are not taken into account.

scheme://host[:[port]]/[path_dir]

  • https://www.domain.com/
  • https://www.domain.com/some/sub/dir/

Methods

__construct()

Constructor calculates all values by incoming variables.

public __construct(array<string|int, mixed> $serverParams, array<string|int, mixed> $configuration, string $pathThisScript, string $pathSite) : mixed

This object is immutable.

All determine*() "detail worker methods" in this class retrieve their dependencies to other properties as method arguments, they are static, stateless and have no dependency to $this. This ensures the chain of inter-property dependencies is visible by only looking at the construct() method.

Parameters
$serverParams : array<string|int, mixed>

, usually coming from $_SERVER or $request->getServerParams()

$configuration : array<string|int, mixed>

$GLOBALS['TYPO3_CONF_VARS']['SYS']

$pathThisScript : string

Absolute server entry script path, usually found within Environment::getCurrentScript()

$pathSite : string

Absolute server path to document root, Environment::getPublicPath()

createFromRequest()

Factory method for creating normalized params from a PSR-7 server request object

public static createFromRequest(ServerRequestInterface $request[, array<string|int, mixed>|null $systemConfiguration = null ]) : static
Parameters
$request : ServerRequestInterface
$systemConfiguration : array<string|int, mixed>|null = null
Return values
static

createFromServerParams()

Factory method, to allow TYPO3 to handle configuration options directly.

public static createFromServerParams(array<string|int, mixed> $serverParams[, array<string|int, mixed>|null $systemConfiguration = null ]) : static
Parameters
$serverParams : array<string|int, mixed>
  • could be fulfilled by $_SERVER (on web requests)
$systemConfiguration : array<string|int, mixed>|null = null
Return values
static

getDocumentRoot()

public getDocumentRoot() : string
Return values
string

Absolute path to web document root, eg. /var/www/typo3

getHttpAcceptEncoding()

Will be deprecated later, use $request->getServerParams()['HTTP_ACCEPT_ENCODING'] instead

public getHttpAcceptEncoding() : string
Return values
string

HTTP_ACCEPT_ENCODING, eg. 'gzip, deflate'

getHttpAcceptLanguage()

Will be deprecated later, use $request->getServerParams()['HTTP_ACCEPT_LANGUAGE'] instead

public getHttpAcceptLanguage() : string
Return values
string

HTTP_ACCEPT_LANGUAGE, eg. 'de-DE,de;q=0.9,en-US;q=0.8,en;q=0.7'

getHttpHost()

public getHttpHost() : string
Return values
string

Sanitized HTTP_HOST value host[:port]

getHttpReferer()

Will be deprecated later, use $request->getServerParams()['HTTP_REFERER'] instead

public getHttpReferer() : string
Return values
string

HTTP_REFERER, eg. 'https://www.domain.com/typo3/index.php?id=42'

getHttpUserAgent()

Will be deprecated later, use $request->getServerParams()['HTTP_USER_AGENT'] instead

public getHttpUserAgent() : string
Return values
string

HTTP_USER_AGENT identifier

getPathInfo()

Will be deprecated later, use getScriptName() as reliable solution instead

public getPathInfo() : string
Return values
string

Script path part of URI, eg. 'typo3/index.php'

getQueryString()

Will be deprecated later, use $request->getServerParams()['QUERY_STRING'] instead

public getQueryString() : string
Return values
string

QUERY_STRING, eg 'id=42&foo=bar'

getRemoteAddress()

public getRemoteAddress() : string
Return values
string

Client IP

getRemoteHost()

Will be deprecated later, use $request->getServerParams()['REMOTE_HOST'] instead

public getRemoteHost() : string
Return values
string

REMOTE_HOST if configured in web server, eg. 'www.clientDomain.com'

getRequestDir()

public getRequestDir() : string
Return values
string

REQUEST URI without script file name and query parts, eg. http://www.domain.com/typo3/

getRequestHost()

public getRequestHost() : string
Return values
string

Sanitized HTTP_HOST with protocol scheme://host[:port], eg. https://www.domain.com/

getRequestHostOnly()

public getRequestHostOnly() : string
Return values
string

Host / domain /IP only, eg. www.domain.com

getRequestPort()

public getRequestPort() : int
Return values
int

Requested port if given, eg. 8080 - often not explicitly given, then 0

getRequestScript()

public getRequestScript() : string
Return values
string

REQUEST URI without query part, eg. http://www.domain.com/typo3/index.php

getRequestUri()

public getRequestUri() : string
Return values
string

Request Uri without domain and protocol, eg. /index.php?id=42

getRequestUrl()

public getRequestUrl() : string
Return values
string

Full REQUEST_URI, eg. http://www.domain.com/typo3/foo/bar?id=42

getScriptFilename()

public getScriptFilename() : string
Return values
string

Absolute entry script path on server, eg. /var/www/typo3/index.php

getScriptName()

public getScriptName() : string
Return values
string

Script path part of URI, eg. '/typo3/index.php'

getSitePath()

public getSitePath() : string
Return values
string

Path part to frontend, eg. /some/sub/dir/

getSiteScript()

public getSiteScript() : string
Return values
string

Path part to entry script with parameters, without sub dir, eg 'typo3/index.php?id=42'

getSiteUrl()

public getSiteUrl() : string
Return values
string

Website frontend url, eg. https://www.domain.com/some/sub/dir/

isBehindReverseProxy()

public isBehindReverseProxy() : bool
Return values
bool

True if request comes from a configured reverse proxy

isHttps()

public isHttps() : bool
Return values
bool

True if client request has been done using HTTPS

determineDocumentRoot()

Calculate absolute path to web document root

protected static determineDocumentRoot(string $scriptNameOnFileSystem, string $scriptFilename) : string
Parameters
$scriptNameOnFileSystem : string

Entry script path of URI on file system, without domain and without query parameters, with leading /

$scriptFilename : string

Absolute path to entry script on server filesystem

Return values
string

Path to document root with trailing slash

determineHttpHost()

Normalize HTTP_HOST by taking proxy configuration into account.

protected static determineHttpHost(array<string|int, mixed> $serverParams, array<string|int, mixed> $configuration, bool $isBehindReverseProxy) : string
Parameters
$serverParams : array<string|int, mixed>

Basically the $_SERVER, but from $request object

$configuration : array<string|int, mixed>

$TYPO3_CONF_VARS['SYS'] array

$isBehindReverseProxy : bool

True if reverse proxy setup is detected

Return values
string

Normalized HTTP_HOST

determineHttps()

Determine if the client called via HTTPS. Takes proxy ssl terminator configurations into account.

protected static determineHttps(array<string|int, mixed> $serverParams, array<string|int, mixed> $configuration) : bool
Parameters
$serverParams : array<string|int, mixed>

Basically the $_SERVER, but from $request object

$configuration : array<string|int, mixed>

$TYPO3_CONF_VARS['SYS'] array

Return values
bool

True if request has been done via HTTPS

determineIsBehindReverseProxy()

Check if a configured reverse proxy setup is detected.

protected static determineIsBehindReverseProxy(array<string|int, mixed> $serverParams, array<string|int, mixed> $configuration) : bool
Parameters
$serverParams : array<string|int, mixed>

Basically the $_SERVER, but from $request object

$configuration : array<string|int, mixed>

$TYPO3_CONF_VARS[SYS] array

Return values
bool

True if TYPO3 is behind a reverse proxy

determineRemoteAddress()

Determine clients REMOTE_ADDR, even if there is a reverse proxy in between.

protected static determineRemoteAddress(array<string|int, mixed> $serverParams, array<string|int, mixed> $configuration, bool $isBehindReverseProxy) : string
Parameters
$serverParams : array<string|int, mixed>

Basically the $_SERVER, but from $request object

$configuration : array<string|int, mixed>

$TYPO3_CONF_VARS[SYS] array

$isBehindReverseProxy : bool

True if reverse proxy setup is detected

Return values
string

Resolved REMOTE_ADDR

determineRequestHostOnly()

HTTP_HOST without port

protected static determineRequestHostOnly(string $httpHost) : string
Parameters
$httpHost : string

host[:[port]]

Return values
string

Resolved host

determineRequestPort()

Requested port if given

protected static determineRequestPort(string $httpHost, string $httpHostOnly) : int
Parameters
$httpHost : string

host[:[port]]

$httpHostOnly : string

host

Return values
int

Resolved port if given, else 0

determineRequestUri()

Determine REQUEST_URI, taking proxy configuration and various web server specifics into account.

protected static determineRequestUri(array<string|int, mixed> $serverParams, array<string|int, mixed> $configuration, bool $isHttps, string $scriptName, bool $isBehindReverseProxy) : string
Parameters
$serverParams : array<string|int, mixed>

Basically the $_SERVER, but from $request object

$configuration : array<string|int, mixed>

$TYPO3_CONF_VARS['SYS'] array

$isHttps : bool

True if used protocol is HTTPS

$scriptName : string

Script name

$isBehindReverseProxy : bool

True if reverse proxy setup is detected

Return values
string

Sanitized REQUEST_URI

determineScriptName()

Determine script name and path

protected static determineScriptName(array<string|int, mixed> $serverParams, array<string|int, mixed> $configuration, bool $isHttps, bool $isBehindReverseProxy) : string
Parameters
$serverParams : array<string|int, mixed>

Basically the $_SERVER, but from $request object

$configuration : array<string|int, mixed>

TYPO3_CONF_VARS['SYS'] array

$isHttps : bool

True if used protocol is HTTPS

$isBehindReverseProxy : bool

True if reverse proxy setup is detected

Return values
string

Sanitized script name

determineSitePath()

Determine site path

protected static determineSitePath(string $requestHost, string $siteUrl) : string
Parameters
$requestHost : string

scheme://host[:port]

$siteUrl : string

Full Frontend Url

Return values
string

determineSiteScript()

Determine site script

protected static determineSiteScript(string $requestUrl, string $siteUrl) : string
Parameters
$requestUrl : string
$siteUrl : string
Return values
string

determineSiteUrl()

Determine frontend url

protected static determineSiteUrl(string $requestDir, string $pathThisScript, string $pathSite) : string
Parameters
$requestDir : string

Full Uri with path, but without script name and query parts

$pathThisScript : string

Absolute path to entry script on server filesystem

$pathSite : string

Absolute server path to document root

Return values
string

Calculated Frontend Url


        
On this page

Search results