TYPO3CMS  8
 All Classes Namespaces Files Functions Variables Pages
SystemEnvironmentBuilder Class Reference

Static Public Member Functions

static run ($entryPointLevel=0)
 
static isFunctionDisabled ($function)
 

Static Protected Member Functions

static defineBaseConstants ()
 
static definePaths ($entryPointLevel=0)
 
static checkMainPathsExist ()
 
static initializeGlobalVariables ()
 
static initializeGlobalTimeTrackingVariables ()
 
static initializeBasicErrorReporting ()
 
static getTypo3Os ()
 
static getPathThisScript ()
 
static getPathThisScriptNonCli ()
 
static getPathThisScriptCli ()
 
static getPathSite ($entryPointLevel)
 
static getUnifiedDirectoryName ($absolutePath)
 
static exitWithMessage ($message)
 

Static Protected Attributes

static $supportedCgiServerApis
 
static $disabledFunctions = null
 

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

Member Function Documentation

static checkMainPathsExist ( )
staticprotected

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

Returns
void

Definition at line 182 of file SystemEnvironmentBuilder.php.

static defineBaseConstants ( )
staticprotected

Define all simple constants that have no dependency to local configuration

Returns
void

Definition at line 85 of file SystemEnvironmentBuilder.php.

static definePaths (   $entryPointLevel = 0)
staticprotected

Calculate all required base paths and set as constants.

Parameters
int$entryPointLevelNumber of subdirectories where the entry script is located under the document root
Returns
void

Definition at line 152 of file SystemEnvironmentBuilder.php.

static exitWithMessage (   $message)
staticprotected

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

Parameters
string$message

Definition at line 403 of file SystemEnvironmentBuilder.php.

References HttpUtility\HTTP_STATUS_500.

static getPathSite (   $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/sysext/install/Start/Install.php.
  • A Backend script: This is the case for the typo3/index.php dispatcher and other entry scripts like 'cli_dispatch.phpsh' or 'typo3/index.php' that are located inside typo3/ directly.
Parameters
int$entryPointLevelNumber of subdirectories where the entry script is located under the document root
Returns
string Absolute path to document root of installation

Definition at line 372 of file SystemEnvironmentBuilder.php.

References GeneralUtility\revExplode().

static getPathThisScript ( )
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.

Returns
string Absolute path to entry script

Definition at line 277 of file SystemEnvironmentBuilder.php.

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

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

static getTypo3Os ( )
staticprotected

Determine the operating system TYPO3 is running on.

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

Definition at line 254 of file SystemEnvironmentBuilder.php.

static getUnifiedDirectoryName (   $absolutePath)
staticprotected

Remove file name from script path and unify for Windows and Unix

Parameters
string$absolutePathAbsolute path to script
Returns
string Directory name of script file location, unified for Windows and Unix without the trailing slash

Definition at line 389 of file SystemEnvironmentBuilder.php.

static 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.

Returns
void

Definition at line 243 of file SystemEnvironmentBuilder.php.

static initializeGlobalTimeTrackingVariables ( )
staticprotected

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

Returns
void

Definition at line 216 of file SystemEnvironmentBuilder.php.

References $GLOBALS, and GeneralUtility\milliseconds().

static initializeGlobalVariables ( )
staticprotected

Set up / initialize several globals variables

Returns
void

Definition at line 201 of file SystemEnvironmentBuilder.php.

References $GLOBALS.

static isFunctionDisabled (   $function)
static

Check if the given function is disabled in the system

Parameters
string$function
Returns
bool

Definition at line 424 of file SystemEnvironmentBuilder.php.

References GeneralUtility\trimExplode().

static run (   $entryPointLevel = 0)
static

Run base setup. This entry method is used in all scopes (FE, BE, eid, ajax, ...)

Definition at line 70 of file SystemEnvironmentBuilder.php.

Referenced by Bootstrap\baseSetup().

Member Data Documentation

$disabledFunctions = null
staticprotected

Definition at line 60 of file SystemEnvironmentBuilder.php.

$supportedCgiServerApis
staticprotected
Initial value:
= [
'fpm-fcgi',
'cgi',
'isapi',
'cgi-fcgi',
'srv',
]

Definition at line 47 of file SystemEnvironmentBuilder.php.