Normalized parameters¶
The normalized
request attribute provide access to server
parameters, for instance, if the TYPO3 installation is behind a reverse proxy.
It is available in frontend and backend context.
Important
The normalized parameters substitute
\TYPO3\
. See the
migration guide below.
One can retrieve the normalized parameters like this:
/** @var \TYPO3\CMS\Core\Http\NormalizedParams $normalizedParams */
$normalizedParams = $request->getAttribute('normalizedParams');
$requestPort = $normalizedParams->getRequestPort();
API¶
- class NormalizedParams ¶
-
- Fully qualified name
-
\TYPO3\
CMS\ Core\ Http\ Normalized Params
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.
- getDocumentRoot ( ) ¶
-
- returntype
-
string
- Returns
-
Absolute path to web document root, eg. /var/www/typo3
- getHttpAcceptEncoding ( ) ¶
-
Will be deprecated later, use $request->getServerParams()['HTTP_ACCEPT_ENCODING'] instead
- returntype
-
string
- Returns
-
HTTP_ACCEPT_ENCODING, eg. 'gzip, deflate'
- getHttpAcceptLanguage ( ) ¶
-
Will be deprecated later, use $request->getServerParams()['HTTP_ACCEPT_LANGUAGE'] instead
- returntype
-
string
- Returns
-
HTTP_ACCEPT_LANGUAGE, eg. 'de-DE,de;q=0.9,en-US;q=0.8,en;q=0.7'
- getHttpHost ( ) ¶
-
- returntype
-
string
- Returns
-
Sanitized HTTP_HOST value host[:port]
- getHttpReferer ( ) ¶
-
Will be deprecated later, use $request->getServerParams()['HTTP_REFERER'] instead
- returntype
-
string
- Returns
-
HTTP_REFERER, eg. 'https://www.domain.com/typo3/index.php?id=42'
- getHttpUserAgent ( ) ¶
-
Will be deprecated later, use $request->getServerParams()['HTTP_USER_AGENT'] instead
- returntype
-
string
- Returns
-
HTTP_USER_AGENT identifier
- getQueryString ( ) ¶
-
Will be deprecated later, use $request->getServerParams()['QUERY_STRING'] instead
- returntype
-
string
- Returns
-
QUERY_STRING, eg 'id=42&foo=bar'
- getPathInfo ( ) ¶
-
Will be deprecated later, use getScriptName() as reliable solution instead
- returntype
-
string
- Returns
-
Script path part of URI, eg. 'typo3/index.php'
- getRemoteAddress ( ) ¶
-
- returntype
-
string
- Returns
-
Client IP
- getRemoteHost ( ) ¶
-
Will be deprecated later, use $request->getServerParams()['REMOTE_HOST'] instead
- returntype
-
string
- Returns
-
REMOTE_HOST if configured in web server, eg. 'www.clientDomain.com'
- getRequestDir ( ) ¶
-
- returntype
-
string
- Returns
-
REQUEST URI without script file name and query parts, eg. http://www.domain.com/typo3/
- getRequestHost ( ) ¶
-
- returntype
-
string
- Returns
-
Sanitized HTTP_HOST with protocol scheme://host[:port], eg. https://www.domain.com/
- getRequestHostOnly ( ) ¶
-
- returntype
-
string
- Returns
-
Host / domain /IP only, eg. www.domain.com
- getRequestPort ( ) ¶
-
- returntype
-
int
- Returns
-
Requested port if given, eg. 8080 - often not explicitly given, then 0
- getRequestScript ( ) ¶
-
- returntype
-
string
- Returns
-
REQUEST URI without query part, eg. http://www.domain.com/typo3/index.php
- getRequestUri ( ) ¶
-
- returntype
-
string
- Returns
-
Request Uri without domain and protocol, eg. /index.php?id=42
- getRequestUrl ( ) ¶
-
- returntype
-
string
- Returns
-
Full REQUEST_URI, eg. http://www.domain.com/typo3/foo/bar?id=42
- getScriptFilename ( ) ¶
-
- returntype
-
string
- Returns
-
Absolute entry script path on server, eg. /var/www/typo3/index.php
- getScriptName ( ) ¶
-
- returntype
-
string
- Returns
-
Script path part of URI, eg. '/typo3/index.php'
- getSitePath ( ) ¶
-
- returntype
-
string
- Returns
-
Path part to frontend, eg. /some/sub/dir/
- getSiteScript ( ) ¶
-
- returntype
-
string
- Returns
-
Path part to entry script with parameters, without sub dir, eg 'typo3/index.php?id=42'
- getSiteUrl ( ) ¶
-
- returntype
-
string
- Returns
-
Website frontend url, eg. https://www.domain.com/some/sub/dir/
- isBehindReverseProxy ( ) ¶
-
- returntype
-
bool
- Returns
-
True if request comes from a configured reverse proxy
- isHttps ( ) ¶
-
- returntype
-
bool
- Returns
-
True if client request has been done using HTTPS
Migrating from GeneralUtility::getIndpEnv()
¶
The class \TYPO3\
is a one-to-one transition
of \TYPO3\
, the old
arguments can be substituted with these calls:
SCRIPT_
is nowNAME ->get
Script Name () SCRIPT_
is nowFILENAME ->get
Script Filename () REQUEST_
is nowURI ->get
Request Uri () TYPO3_
is nowREV_ PROXY ->is
Behind Reverse Proxy () REMOTE_
is nowADDR ->get
Remote Address () HTTP_
is nowHOST ->get
Http Host () TYPO3_
is nowDOCUMENT_ ROOT ->get
Document Root () TYPO3_
is nowHOST_ ONLY ->get
Request Host Only () TYPO3_
is nowPORT ->get
Request Port () TYPO3_
is nowREQUEST_ HOST ->get
Request Host () TYPO3_
is nowREQUEST_ URL ->get
Request Url () TYPO3_
is nowREQUEST_ SCRIPT ->get
Request Script () TYPO3_
is nowREQUEST_ DIR ->get
Request Dir () TYPO3_
is nowSITE_ URL ->get
Site Url () TYPO3_
is nowSITE_ PATH ->get
Site Path () TYPO3_
is nowSITE_ SCRIPT ->get
Site Script () TYPO3_
is nowSSL ->is
Https ()
Some further old get
arguments directly access $request->server
and do not apply any
normalization. These have been transferred to the new class, too, but will be deprecated later if the Core does not use
them anymore:
PATH_
is nowINFO ->get
, but better usePath Info () ->get
insteadScript Name () HTTP_
is nowREFERER ->get
, but better useHttp Referer () $request->get
insteadServer Params () ['HTTP_ REFERER'] HTTP_
is nowUSER_ AGENT ->get
, but better useHttp User Agent () $request->get
insteadServer Params () ['HTTP_ USER_ AGENT'] HTTP_
is nowACCEPT_ ENCODING ->get
, but better useHttp Accept Encoding () $request->get
insteadServer Params () ['HTTP_ ACCEPT_ ENCODING'] HTTP_
is nowACCEPT_ LANGUAGE ->get
, but better useHttp Accept Language () $request->get
insteadServer Params () ['HTTP_ ACCEPT_ LANGUAGE'] REMOTE_
is nowHOST ->get
, but better useRemote Host () $request->get
insteadServer Params () ['REMOTE_ HOST'] QUERY_
is nowSTRING ->get
, but better useQuery String () $request->get
insteadServer Params () ['QUERY_ STRING']