‪TYPO3CMS  10.4
TYPO3\CMS\Core\Core\SystemEnvironmentBuilder Class Reference

Static Public Member Functions

static run (int $entryPointLevel=0, int $requestType=self::REQUESTTYPE_FE)
 

Public Attributes

const REQUESTTYPE_FE = 1
 
const REQUESTTYPE_BE = 2
 
const REQUESTTYPE_CLI = 4
 
const REQUESTTYPE_AJAX = 8
 
const REQUESTTYPE_INSTALL = 16
 

Static Protected Member Functions

static ApplicationContext createApplicationContext ()
 
static defineBaseConstants ()
 
static string calculateScriptPath (int $entryPointLevel, int $requestType)
 
static string calculateRootPath (int $entryPointLevel, int $requestType)
 
static initializeGlobalVariables ()
 
static initializeGlobalTimeTrackingVariables ()
 
static initializeEnvironment (int $requestType, string $scriptPath, string $sitePath)
 
static isRunningOnWindows ()
 
static string getPathThisScript (bool $isCli)
 
static string getPathThisScriptNonCli ()
 
static string getPathThisScriptCli ()
 
static string getRootPathFromScriptPath ($scriptPath, $entryPointLevel)
 
static bool usesComposerClassLoading ()
 
static defineTypo3RequestTypes ()
 
static setRequestType (int $requestType)
 
static defineLegacyConstants (string $mode)
 
static bool isCliRequestType (?int $requestType)
 

Detailed Description

Class to encapsulate base setup of bootstrap.

This class contains all code that must be executed by every entry script.

It sets up all basic paths, constants, global variables and checks the basic environment TYPO3 runs in.

This class does not use any TYPO3 instance specific configuration, it only sets up things based on the server environment and core code. Even with a missing typo3conf/LocalConfiguration.php this script will be successful.

The script aborts execution with an error message if some part fails or conditions are not met.

This script is internal code and subject to change. DO NOT use it in own code, or be prepared your code might break in future versions of the core.

Definition at line 41 of file SystemEnvironmentBuilder.php.

Member Function Documentation

◆ calculateRootPath()

static string TYPO3\CMS\Core\Core\SystemEnvironmentBuilder::calculateRootPath ( int  $entryPointLevel,
int  $requestType 
)
staticprotected

Absolute path to the "classic" site root of the TYPO3 application. This semantically refers to the directory where executable server-side code, configuration and runtime files are located (e.g. typo3conf/ext, typo3/sysext, typo3temp/var). In practice this is always identical to the public web document root path which contains files that are served by the webserver directly (fileadmin/ and public resources).

This is not to be confused with the app-path that is used in composer-mode installations (by default). Resources in app-path are located outside the document root.

Parameters
int$entryPointLevel‪Number of subdirectories where the entry script is located under the document root
int$requestType
Returns
‪string Absolute path without trailing slash

Definition at line 201 of file SystemEnvironmentBuilder.php.

References TYPO3\CMS\Core\Core\SystemEnvironmentBuilder\getRootPathFromScriptPath(), and TYPO3\CMS\Core\Core\SystemEnvironmentBuilder\isCliRequestType().

Referenced by TYPO3\CMS\Core\Core\SystemEnvironmentBuilder\run().

◆ calculateScriptPath()

static string TYPO3\CMS\Core\Core\SystemEnvironmentBuilder::calculateScriptPath ( int  $entryPointLevel,
int  $requestType 
)
staticprotected

Calculate script path. This is the absolute path to the entry script. Can be something like '.../public/index.php' or '.../public/typo3/index.php' for web calls, or '.../bin/typo3' or similar for cli calls.

Parameters
int$entryPointLevel‪Number of subdirectories where the entry script is located under the document root
int$requestType
Returns
‪string Absolute path to entry script

Definition at line 161 of file SystemEnvironmentBuilder.php.

References TYPO3\CMS\Core\Core\SystemEnvironmentBuilder\getRootPathFromScriptPath(), and TYPO3\CMS\Core\Core\SystemEnvironmentBuilder\isCliRequestType().

Referenced by TYPO3\CMS\Core\Core\SystemEnvironmentBuilder\run().

◆ createApplicationContext()

static ApplicationContext TYPO3\CMS\Core\Core\SystemEnvironmentBuilder::createApplicationContext ( )
staticprotected

Some notes:

HTTP_TYPO3_CONTEXT -> used with Apache suexec support REDIRECT_TYPO3_CONTEXT -> used under some circumstances when value is set in the webserver and proxying the values to FPM

Returns
ApplicationContext
Exceptions

Definition at line 84 of file SystemEnvironmentBuilder.php.

◆ defineBaseConstants()

static TYPO3\CMS\Core\Core\SystemEnvironmentBuilder::defineBaseConstants ( )
staticprotected

Define all simple constants that have no dependency to local configuration

Deprecated:
‪use FileNameAccess class to retrieve this information, will be removed in TYPO3 v11.0
Deprecated:
‪use FILE_DENY_PATTERN and FileNameAccess class to retrieve this information, will be removed in TYPO3 v11.0
Deprecated:
‪use Typo3Information class to retrieve this information, will be removed in TYPO3 v11.0
Deprecated:
‪use Typo3Information class to retrieve this information, will be removed in TYPO3 v11.0
Deprecated:
‪use Typo3Information class to retrieve this information, will be removed in TYPO3 v11.0
Deprecated:
‪use Typo3Information class to retrieve this information, will be removed in TYPO3 v11.0
Deprecated:
‪use Typo3Information class to retrieve this information, will be removed in TYPO3 v11.0
Deprecated:
‪use Typo3Information class to retrieve this information, will be removed in TYPO3 v11.0

Definition at line 93 of file SystemEnvironmentBuilder.php.

References TYPO3\CMS\Core\Resource\Security\FileNameValidator\DEFAULT_FILE_DENY_PATTERN.

Referenced by TYPO3\CMS\Core\Core\SystemEnvironmentBuilder\run().

◆ defineLegacyConstants()

static TYPO3\CMS\Core\Core\SystemEnvironmentBuilder::defineLegacyConstants ( string  $mode)
staticprotected

Define constants and variables

Parameters
string$mode

Definition at line 422 of file SystemEnvironmentBuilder.php.

Referenced by TYPO3\CMS\Core\Core\SystemEnvironmentBuilder\run().

◆ defineTypo3RequestTypes()

static TYPO3\CMS\Core\Core\SystemEnvironmentBuilder::defineTypo3RequestTypes ( )
staticprotected

Define TYPO3_REQUESTTYPE* constants that can be used for developers to see if any context has been hit also see setRequestType(). Is done at the very beginning so these parameters are always available.

Definition at line 388 of file SystemEnvironmentBuilder.php.

Referenced by TYPO3\CMS\Core\Core\SystemEnvironmentBuilder\run().

◆ getPathThisScript()

static string TYPO3\CMS\Core\Core\SystemEnvironmentBuilder::getPathThisScript ( bool  $isCli)
staticprotected

Calculate script path.

First step in path calculation: Goal is to find the absolute path of the entry script that was called without resolving any links. This is important since the TYPO3 entry points are often linked to a central core location, so we can not use the php magic FILE here, but resolve the called script path from given server environments.

This path is important to calculate the document root. The strategy is to find out the script name that was called in the first place and to subtract the local part from it to find the document root.

Parameters
bool$isCli
Returns
‪string Absolute path to entry script

Definition at line 299 of file SystemEnvironmentBuilder.php.

References TYPO3\CMS\Core\Core\SystemEnvironmentBuilder\getPathThisScriptCli(), and TYPO3\CMS\Core\Core\SystemEnvironmentBuilder\getPathThisScriptNonCli().

◆ getPathThisScriptCli()

static string TYPO3\CMS\Core\Core\SystemEnvironmentBuilder::getPathThisScriptCli ( )
staticprotected

Calculate path to entry script if in cli mode.

First argument of a cli script is the path to the script that was called. If the script does not start with / (or A:\ for Windows), the path is not absolute yet, and the current working directory is added.

Returns
‪string Absolute path to entry script

Definition at line 329 of file SystemEnvironmentBuilder.php.

Referenced by TYPO3\CMS\Core\Core\SystemEnvironmentBuilder\getPathThisScript().

◆ getPathThisScriptNonCli()

static string TYPO3\CMS\Core\Core\SystemEnvironmentBuilder::getPathThisScriptNonCli ( )
staticprotected

Return path to entry script if not in cli mode.

Returns
‪string Absolute path to entry script

Definition at line 312 of file SystemEnvironmentBuilder.php.

References TYPO3\CMS\Core\Core\Environment\isRunningOnCgiServer(), and TYPO3\CMS\Core\Core\Environment\usesCgiFixPathInfo().

Referenced by TYPO3\CMS\Core\Core\SystemEnvironmentBuilder\getPathThisScript().

◆ getRootPathFromScriptPath()

static string TYPO3\CMS\Core\Core\SystemEnvironmentBuilder::getRootPathFromScriptPath (   $scriptPath,
  $entryPointLevel 
)
staticprotected

Calculate the document root part to the instance from $scriptPath. This is based on the amount of subdirectories "under" root path where $scriptPath is located.

The following main scenarios for entry points exist by default in the TYPO3 core:

  • ‪Directly called documentRoot/index.php (-> FE call or eiD include): index.php is located in the same directory as the main project. The document root is identical to the directory the script is located at.
  • ‪The install tool, located under typo3/install.php.
  • ‪A Backend script: This is the case for the typo3/index.php dispatcher and other entry scripts like 'typo3/sysext/core/bin/typo3' or 'typo3/index.php' that are located inside typo3/ directly.
Parameters
string$scriptPath‪Calculated path to the entry script
int$entryPointLevel‪Number of subdirectories where the entry script is located under the document root
Returns
‪string Absolute path to document root of installation without trailing slash

Definition at line 365 of file SystemEnvironmentBuilder.php.

References TYPO3\CMS\Core\Utility\PathUtility\dirnameDuringBootstrap(), and TYPO3\CMS\Core\Utility\GeneralUtility\revExplode().

Referenced by TYPO3\CMS\Core\Core\SystemEnvironmentBuilder\calculateRootPath(), and TYPO3\CMS\Core\Core\SystemEnvironmentBuilder\calculateScriptPath().

◆ initializeEnvironment()

static TYPO3\CMS\Core\Core\SystemEnvironmentBuilder::initializeEnvironment ( int  $requestType,
string  $scriptPath,
string  $sitePath 
)
staticprotected

Initialize the Environment class

Parameters
int$requestType
string$scriptPath
string$sitePath

Definition at line 246 of file SystemEnvironmentBuilder.php.

References TYPO3\CMS\Core\Core\Environment\initialize().

Referenced by TYPO3\CMS\Core\Core\SystemEnvironmentBuilder\run().

◆ initializeGlobalTimeTrackingVariables()

static TYPO3\CMS\Core\Core\SystemEnvironmentBuilder::initializeGlobalTimeTrackingVariables ( )
staticprotected

Initialize global time tracking variables. These are helpers to for example output script parsetime at the end of a script.

Definition at line 226 of file SystemEnvironmentBuilder.php.

References $GLOBALS.

Referenced by TYPO3\CMS\Core\Core\SystemEnvironmentBuilder\run().

◆ initializeGlobalVariables()

static TYPO3\CMS\Core\Core\SystemEnvironmentBuilder::initializeGlobalVariables ( )
staticprotected

Set up / initialize several globals variables

Definition at line 216 of file SystemEnvironmentBuilder.php.

References $GLOBALS.

Referenced by TYPO3\CMS\Core\Core\SystemEnvironmentBuilder\run().

◆ isCliRequestType()

static bool TYPO3\CMS\Core\Core\SystemEnvironmentBuilder::isCliRequestType ( ?int  $requestType)
staticprotected

Checks if request type is cli. Falls back to check PHP_SAPI in case request type is not provided

Parameters
int | null$requestType
Returns
‪bool

Definition at line 439 of file SystemEnvironmentBuilder.php.

References TYPO3\CMS\Core\Core\SystemEnvironmentBuilder\REQUESTTYPE_CLI, and TYPO3\CMS\Core\Core\SystemEnvironmentBuilder\REQUESTTYPE_FE.

Referenced by TYPO3\CMS\Core\Core\SystemEnvironmentBuilder\calculateRootPath(), and TYPO3\CMS\Core\Core\SystemEnvironmentBuilder\calculateScriptPath().

◆ isRunningOnWindows()

static TYPO3\CMS\Core\Core\SystemEnvironmentBuilder::isRunningOnWindows ( )
staticprotected

Determine if the operating system TYPO3 is running on is windows.

Definition at line 277 of file SystemEnvironmentBuilder.php.

◆ run()

static TYPO3\CMS\Core\Core\SystemEnvironmentBuilder::run ( int  $entryPointLevel = 0,
int  $requestType = self::REQUESTTYPE_FE 
)
static

◆ setRequestType()

static TYPO3\CMS\Core\Core\SystemEnvironmentBuilder::setRequestType ( int  $requestType)
staticprotected

Defines the TYPO3_REQUESTTYPE constant so the environment knows which context the request is running.

Parameters
int$requestType

Definition at line 407 of file SystemEnvironmentBuilder.php.

Referenced by TYPO3\CMS\Core\Core\SystemEnvironmentBuilder\run().

◆ usesComposerClassLoading()

static bool TYPO3\CMS\Core\Core\SystemEnvironmentBuilder::usesComposerClassLoading ( )
staticprotected
Returns
‪bool

Definition at line 379 of file SystemEnvironmentBuilder.php.

Member Data Documentation

◆ REQUESTTYPE_AJAX

const TYPO3\CMS\Core\Core\SystemEnvironmentBuilder::REQUESTTYPE_AJAX = 8

◆ REQUESTTYPE_BE

◆ REQUESTTYPE_CLI

const TYPO3\CMS\Core\Core\SystemEnvironmentBuilder::REQUESTTYPE_CLI = 4

◆ REQUESTTYPE_FE

◆ REQUESTTYPE_INSTALL

const TYPO3\CMS\Core\Core\SystemEnvironmentBuilder::REQUESTTYPE_INSTALL = 16