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

Static Public Member Functions

static run (int $entryPointLevel=0, int $requestType=self::REQUESTTYPE_FE)
 
static initializeEnvironment (ApplicationContext $context, int $requestType=null)
 
static bool isFunctionDisabled ($function)
 

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 definePaths (int $entryPointLevel, int $requestType)
 
static checkMainPathsExist ()
 
static initializeGlobalVariables ()
 
static initializeGlobalTimeTrackingVariables ()
 
static initializeBasicErrorReporting ()
 
static string getTypo3Os ()
 
static string getPathThisScript (bool $isCli)
 
static string getPathThisScriptNonCli ()
 
static string getPathThisScriptCli ()
 
static string getRootPathFromScriptPath ($scriptPath, $entryPointLevel)
 
static exitWithMessage ($message)
 
static bool usesComposerClassLoading ()
 
static defineTypo3RequestTypes ()
 
static setRequestType (int $requestType)
 
static defineLegacyConstants (string $mode)
 
static bool isCliRequestType (?int $requestType)
 

Static Protected Attributes

static array $supportedCgiServerApis
 
static string[] $disabledFunctions
 

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/localconf.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 40 of file SystemEnvironmentBuilder.php.

Member Function Documentation

◆ checkMainPathsExist()

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

Check if path and script file name calculation was successful, exit if not.

Definition at line 248 of file SystemEnvironmentBuilder.php.

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 106 of file SystemEnvironmentBuilder.php.

◆ defineBaseConstants()

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

Define all simple constants that have no dependency to local configuration

Definition at line 116 of file SystemEnvironmentBuilder.php.

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

Definition at line 548 of file SystemEnvironmentBuilder.php.

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

◆ definePaths()

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

Calculate all required base paths and set as constants.

Parameters
int$entryPointLevel‪Number of subdirectories where the entry script is located under the document root
int$requestType

Definition at line 193 of file SystemEnvironmentBuilder.php.

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

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 518 of file SystemEnvironmentBuilder.php.

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

◆ exitWithMessage()

static TYPO3\CMS\Core\Core\SystemEnvironmentBuilder::exitWithMessage (   $message)
staticprotected

Send http headers, echo out a text message and exit with error code

Parameters
string$message

Definition at line 473 of file SystemEnvironmentBuilder.php.

References TYPO3\CMS\Core\Utility\HttpUtility\HTTP_STATUS_500.

◆ getPathThisScript()

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

Calculate PATH_thisScript

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 (PATH_site). 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 366 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 409 of file SystemEnvironmentBuilder.php.

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

◆ getPathThisScriptNonCli()

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

Calculate path to entry script if not in cli mode.

Depending on the environment, the script path is found in different $_SERVER variables.

Returns
‪string Absolute path to entry script

Definition at line 381 of file SystemEnvironmentBuilder.php.

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 PATH_thisScript. This is based on the amount of subdirectories "under" PATH_site where PATH_thisScript 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

Definition at line 457 of file SystemEnvironmentBuilder.php.

References TYPO3\CMS\Core\Utility\PathUtility\dirnameDuringBootstrap().

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

◆ getTypo3Os()

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

Determine the operating system TYPO3 is running on.

Returns
‪string Either 'WIN' if running on Windows, else empty string

Definition at line 342 of file SystemEnvironmentBuilder.php.

◆ initializeBasicErrorReporting()

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

Initialize basic error reporting.

There are a lot of extensions that have no strict / notice / deprecated free ext_localconf or ext_tables. Since the final error reporting must be set up after those extension files are read, a default configuration is needed to suppress error reporting meanwhile during further bootstrap.

Definition at line 331 of file SystemEnvironmentBuilder.php.

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

◆ initializeEnvironment()

static TYPO3\CMS\Core\Core\SystemEnvironmentBuilder::initializeEnvironment ( ApplicationContext  $context,
int  $requestType = null 
)
static

Initialize the Environment class

Parameters
ApplicationContext$context
int | null$requestType

Definition at line 291 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 270 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 258 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 563 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\definePaths().

◆ isFunctionDisabled()

static bool TYPO3\CMS\Core\Core\SystemEnvironmentBuilder::isFunctionDisabled (   $function)
static

Check if the given function is disabled in the system

Parameters
string$function
Returns
‪bool

Definition at line 494 of file SystemEnvironmentBuilder.php.

Referenced by TYPO3\CMS\Backend\Backend\ToolbarItems\SystemInformationToolbarItem\getGitRevision().

◆ 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 535 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 509 of file SystemEnvironmentBuilder.php.

Member Data Documentation

◆ $disabledFunctions

string [] TYPO3\CMS\Core\Core\SystemEnvironmentBuilder::$disabledFunctions
staticprotected

An array of disabled methods

Definition at line 71 of file SystemEnvironmentBuilder.php.

◆ $supportedCgiServerApis

array TYPO3\CMS\Core\Core\SystemEnvironmentBuilder::$supportedCgiServerApis
staticprotected
Initial value:
= array(
'fpm-fcgi',
'cgi',
'isapi',
'cgi-fcgi',
'srv',
)

A list of supported CGI server APIs NOTICE: This is a duplicate of the SAME array in GeneralUtility! It is duplicated here as this information is needed early in bootstrap and GeneralUtility is not available yet.

Definition at line 59 of file SystemEnvironmentBuilder.php.

◆ REQUESTTYPE_AJAX

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

Definition at line 49 of file SystemEnvironmentBuilder.php.

◆ REQUESTTYPE_BE

const TYPO3\CMS\Core\Core\SystemEnvironmentBuilder::REQUESTTYPE_BE = 2

Definition at line 45 of file SystemEnvironmentBuilder.php.

◆ REQUESTTYPE_CLI

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

◆ REQUESTTYPE_FE

const TYPO3\CMS\Core\Core\SystemEnvironmentBuilder::REQUESTTYPE_FE = 1

◆ REQUESTTYPE_INSTALL

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

Definition at line 51 of file SystemEnvironmentBuilder.php.