TYPO3 CMS  TYPO3_6-2
TYPO3\CMS\Core\Core\SystemEnvironmentBuilder Class Reference

Static Public Member Functions

static run ($relativePathPart='')
 

Static Protected Member Functions

static defineBaseConstants ()
 
static definePaths ($relativePathPart='')
 
static checkMainPathsExist ()
 
static handleMagicQuotesGpc ()
 
static addCorePearPathToIncludePath ()
 
static initializeGlobalVariables ()
 
static initializeGlobalTimeTrackingVariables ()
 
static initializeBasicErrorReporting ()
 
static getTypo3Os ()
 
static getPathThisScript ()
 
static getPathThisScriptNonCli ()
 
static getPathThisScriptCli ()
 
static getPathSite ($relativePathPart)
 
static getPathSiteByTypo3ModulePath ()
 
static getPathSiteByRelativePathPart ($relativePathPart)
 
static getUnifiedDirectoryNameWithTrailingSlash ($absolutePath)
 
static dieWithMessage ($message)
 

Static Protected Attributes

static $supportedCgiServerApis
 

Detailed Description

This file is part of the TYPO3 CMS project.

It is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, either version 2 of the License, or any later version.

For the full copyright and license information, please read the LICENSE.txt file that was distributed with this source code.

The TYPO3 project - inspiring people to share! 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 36 of file SystemEnvironmentBuilder.php.

Member Function Documentation

◆ addCorePearPathToIncludePath()

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

Add typo3/contrib/pear/ as first include folder in include path, because the shipped PEAR packages use relative paths to include their files.

This is required for to work.

Having the TYPO3 folder first will make sure that the shipped version is loaded before any local PEAR package, thus avoiding any incompatibilities with newer or older versions.

Returns
void

Definition at line 221 of file SystemEnvironmentBuilder.php.

◆ checkMainPathsExist()

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

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

Returns
void

Definition at line 179 of file SystemEnvironmentBuilder.php.

◆ defineBaseConstants()

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

Define all simple constants that have no dependency to local configuration

Returns
void

Definition at line 77 of file SystemEnvironmentBuilder.php.

◆ definePaths()

static TYPO3\CMS\Core\Core\SystemEnvironmentBuilder::definePaths (   $relativePathPart = '')
staticprotected

Calculate all required base paths and set as constants.

Parameters
string$relativePathPartRelative path of the entry script back to document root
Returns
void

Definition at line 142 of file SystemEnvironmentBuilder.php.

References TYPO3_MOD_PATH.

◆ dieWithMessage()

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

Echo out a text message and die

Parameters
string$message

Definition at line 477 of file SystemEnvironmentBuilder.php.

References die.

◆ getPathSite()

static TYPO3\CMS\Core\Core\SystemEnvironmentBuilder::getPathSite (   $relativePathPart)
staticprotected

Calculate the document root part to the instance from PATH_thisScript

There are two ways to hint correct calculation: Either an explicit specified sub path or the defined constant TYPO3_MOD_PATH. Which one is used depends on which entry script was called in the first place.

We have two main scenarios for entry points:

  • Directly called documentRoot/index.php (-> FE call or eiD include): index.php sets $relativePathPart to empty string to hint this code that the document root is identical to the directory the script is located at.
  • An indirect include of typo3/init.php (-> a backend module, the install tool, or scripts like thumbs.php). If init.php is included we distinguish two cases: – A backend module defines 'TYPO3_MOD_PATH': This is the case for "old" modules that are not called through "mod.php" dispatcher, and in the install tool. The TYPO3_MOD_PATH defines the relative path to the typo3/ directory. This is taken as base to calculate the document root. – A script includes init.php and does not define 'TYPO3_MOD_PATH': This is the case for the mod.php dispatcher and other entry scripts like 'cli_dispatch.phpsh' or 'thumbs.php' that are located parallel to init.php. In this case init.php sets 'typo3/' as $relativePathPart as base to calculate the document root.

This basically boils down to the following code: If TYPO3_MOD_PATH is defined, subtract this 'local' part from the entry point directory, else use $relativePathPart to subtract this from the the script entry point to find out the document root.

Parameters
string$relativePathPartRelative directory part from document root to script path if TYPO3_MOD_PATH is not used
Returns
string Absolute path to document root of installation

Definition at line 408 of file SystemEnvironmentBuilder.php.

◆ getPathSiteByRelativePathPart()

static TYPO3\CMS\Core\Core\SystemEnvironmentBuilder::getPathSiteByRelativePathPart (   $relativePathPart)
staticprotected

Find out document root by subtracting $relativePathPart from PATH_thisScript

Parameters
string$relativePathPartRelative part of script from document root
Returns
string Absolute path to document root of installation

Definition at line 448 of file SystemEnvironmentBuilder.php.

◆ getPathSiteByTypo3ModulePath()

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

Calculate document root by TYPO3_MOD_PATH

TYPO3_MOD_PATH can have the following values:

  • "sysext/extensionName/path/entryScript.php" -> extension is below 'docRoot'/typo3/sysext
  • "ext/extensionName/path/entryScript.php" -> extension is below 'docRoot'/typo3/ext
  • "../typo3conf/ext/extensionName/path/entryScript.php" -> extension is below 'docRoot'/typo3conf/ext
  • "install/index.php" -> install tool in 'docRoot'/typo3/install/

The method unifies the above and subtracts the calculated path part from PATH_thisScript

Returns
string Absolute path to document root of installation

Definition at line 430 of file SystemEnvironmentBuilder.php.

References TYPO3_MOD_PATH.

◆ getPathThisScript()

static TYPO3\CMS\Core\Core\SystemEnvironmentBuilder::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 304 of file SystemEnvironmentBuilder.php.

◆ getPathThisScriptCli()

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

◆ getPathThisScriptNonCli()

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

◆ getTypo3Os()

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

◆ getUnifiedDirectoryNameWithTrailingSlash()

static TYPO3\CMS\Core\Core\SystemEnvironmentBuilder::getUnifiedDirectoryNameWithTrailingSlash (   $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

Definition at line 464 of file SystemEnvironmentBuilder.php.

◆ handleMagicQuotesGpc()

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

Compatibility layer for magic quotes

Returns
void

Definition at line 197 of file SystemEnvironmentBuilder.php.

References $GLOBALS, and TYPO3\CMS\Core\Utility\GeneralUtility\addSlashesOnArray().

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

Returns
void

Definition at line 272 of file SystemEnvironmentBuilder.php.

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

Returns
void

Definition at line 246 of file SystemEnvironmentBuilder.php.

References $GLOBALS, and TYPO3\CMS\Core\Utility\GeneralUtility\milliseconds().

◆ initializeGlobalVariables()

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

Set up / initialize several globals variables

Returns
void

Definition at line 230 of file SystemEnvironmentBuilder.php.

References $GLOBALS, and TYPO3\CMS\Core\Utility\GeneralUtility\clientInfo().

◆ run()

static TYPO3\CMS\Core\Core\SystemEnvironmentBuilder::run (   $relativePathPart = '')
static

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

Definition at line 61 of file SystemEnvironmentBuilder.php.

Referenced by TYPO3\CMS\Core\Core\Bootstrap\baseSetup().

Member Data Documentation

◆ $supportedCgiServerApis

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

Definition at line 45 of file SystemEnvironmentBuilder.php.