‪TYPO3CMS  11.5
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 40 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 160 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 120 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 83 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 92 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$mode
Deprecated:
‪since v11, method can be removed in v12

Definition at line 391 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.

Deprecated:
‪since v11, method can be removed in v12

Definition at line 349 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 258 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 288 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 271 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 324 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 205 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 185 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 175 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 409 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 236 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
Deprecated:
‪since v11, method can be removed in v12

Definition at line 374 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 338 of file SystemEnvironmentBuilder.php.

Member Data Documentation

◆ REQUESTTYPE_AJAX

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

◆ REQUESTTYPE_BE

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

Definition at line 45 of file SystemEnvironmentBuilder.php.

Referenced by TYPO3\CMS\Core\Tests\Unit\Configuration\TypoScript\ConditionMatching\AbstractConditionMatcherTest\checkConditionMatcherForRequestFunction(), TYPO3\CMS\Backend\Command\ResetPasswordCommand\createFakeWebRequest(), TYPO3\CMS\Backend\Http\Application\handle(), TYPO3\CMS\Core\Http\ApplicationType\isBackend(), TYPO3\CMS\Core\Tests\Unit\Http\ApplicationTypeTest\isBackendReturnsTrueIfBackend(), TYPO3\CMS\Core\Tests\Unit\Http\ApplicationTypeTest\isFrontendReturnsFalseIfNotFrontend(), TYPO3\CMS\Frontend\Tests\Functional\Imaging\GifBuilderTest\overlayImagesHasStableHash(), TYPO3\CMS\Core\Tests\Functional\Page\PageRendererTest\pageRendererMergesRequireJsPackagesOnConsecutiveCalls(), TYPO3\CMS\Core\Tests\Functional\Page\PageRendererTest\pageRendererRendersFooterValuesDataProvider(), TYPO3\CMS\Core\Tests\Functional\Page\PageRendererTest\pageRendererRendersInsertsMainContentStringsInOutput(), TYPO3\CMS\Core\Tests\Functional\Page\PageRendererTest\pageRendererRendersNomoduleJavascript(), TYPO3\CMS\Extbase\Tests\Functional\Mvc\Web\RequestBuilderTest\prepareServerRequest(), TYPO3\CMS\Backend\Tests\Functional\Controller\EditDocumentControllerTest\processedDataDoesNotOverridePostWithDefaultValues(), TYPO3\CMS\Backend\Tests\Functional\Controller\EditDocumentControllerTest\processedDataTakesOverDefaultValues(), TYPO3\CMS\Fluid\Tests\Functional\ViewHelpers\Link\EmailViewHelperTest\renderCreatesProperMarkupInBackend(), TYPO3\CMS\Fluid\Tests\FunctionalDeprecated\ViewHelpers\Uri\EmailViewHelperTest\renderCreatesProperMarkupInBackend(), TYPO3\CMS\Fluid\Tests\Functional\ViewHelpers\Link\EmailViewHelperTest\renderCreatesProperMarkupInBackendWithEmptyChild(), TYPO3\CMS\Impexp\Tests\Functional\Export\ExportControllerTest\resetExcludedRecords(), TYPO3\CMS\Extbase\Tests\Functional\Mvc\Web\RequestBuilderTest\resolveActionNameReturnsActionDefinedViaPageArgumentOfServerRequest(), TYPO3\CMS\Extbase\Tests\Functional\Mvc\Web\RequestBuilderTest\resolveActionNameReturnsActionDefinedViaParametersOfServerRequest(), TYPO3\CMS\Extbase\Tests\Functional\Mvc\Web\RequestBuilderTest\resolveActionNameReturnsActionDefinedViaParsedBodyOfServerRequest(), TYPO3\CMS\Backend\Tests\Functional\Template\Components\Buttons\Action\ShortcutButtonTest\setUp(), TYPO3\CMS\Backend\Tests\Functional\ViewHelpers\Link\EditRecordViewHelperTest\setUp(), TYPO3\CMS\Backend\Tests\Functional\ViewHelpers\Uri\EditRecordViewHelperTest\setUp(), TYPO3\CMS\Backend\Tests\Functional\ViewHelpers\Link\NewRecordViewHelperTest\setUp(), TYPO3\CMS\Backend\Tests\Functional\ViewHelpers\Uri\NewRecordViewHelperTest\setUp(), TYPO3\CMS\Backend\Tests\Functional\Controller\MfaAjaxControllerTest\setUp(), TYPO3\CMS\Fluid\Tests\Functional\ViewHelpers\Transform\HtmlViewHelperTest\setUp(), TYPO3\CMS\Backend\Tests\Functional\View\PageLayoutViewTest\setUp(), TYPO3\CMS\Extbase\Tests\Functional\Mvc\Controller\ActionControllerArgumentTest\setUp(), TYPO3\CMS\Impexp\Tests\Functional\AbstractImportExportTestCase\setUp(), TYPO3\CMS\Backend\Tests\Functional\Controller\MfaConfigurationControllerTest\setUp(), TYPO3\CMS\Backend\Tests\Functional\Controller\ResetPasswordControllerTest\setUp(), TYPO3\CMS\Backend\Tests\Functional\Controller\MfaSetupControllerTest\setUp(), TYPO3\CMS\Backend\Tests\Functional\Controller\MfaControllerTest\setUp(), TYPO3\CMS\Extbase\Tests\Functional\Persistence\Generic\Storage\Typo3DbQueryParserTest\tcaWithoutCtrlCreatesAValidSQLStatement(), TYPO3\CMS\Impexp\Tests\Functional\Export\ExportControllerTest\throwsPropagateResponseExceptionOnDownloadExportFile(), and TYPO3\CMS\Extbase\Tests\Unit\Persistence\Generic\Storage\Typo3DbBackendTest\uidOfAlreadyPersistedValueObjectIsDeterminedCorrectly().

◆ REQUESTTYPE_CLI

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

◆ REQUESTTYPE_FE

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

Definition at line 43 of file SystemEnvironmentBuilder.php.

Referenced by TYPO3\CMS\Install\Tests\Unit\ExtensionScanner\Php\Matcher\Fixtures\ClassConstantMatcherFixture\aMethod(), TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\createVersionNumberedFilenameKeepsInvalidAbsolutePathInFrontendAndAddsQueryString(), TYPO3\CMS\Form\Tests\Unit\Mvc\Configuration\ConfigurationManagerTest\getConfigurationDoesNotEvaluateTypoScriptLookalikeInstructionsFromYamlSettingsInFrontendContext(), TYPO3\CMS\Core\Tests\Unit\Domain\Repository\PageRepositoryTest\getExtUrlForDokType3PrependsSiteUrl(), TYPO3\CMS\Frontend\Http\Application\handle(), TYPO3\CMS\Frontend\Tests\Unit\Controller\TypoScriptFrontendControllerTest\headerAndFooterMarkersAreReplacedDuringIntProcessing(), TYPO3\CMS\Core\Tests\Unit\Http\ApplicationTypeTest\isBackendReturnsTrueIfNotBackend(), TYPO3\CMS\Core\Core\SystemEnvironmentBuilder\isCliRequestType(), TYPO3\CMS\Core\Http\ApplicationType\isFrontend(), TYPO3\CMS\Core\Tests\Unit\Http\ApplicationTypeTest\isFrontendReturnsTrueIfFrontend(), TYPO3\CMS\FrontendLogin\Tests\Unit\Validation\RedirectUrlValidatorTest\isInCurrentDomainIgnoresScheme(), TYPO3\CMS\Frontend\Tests\Unit\Controller\TypoScriptFrontendControllerTest\languageServiceIsSetUpWithSiteLanguageTypo3LanguageInConstructor(), TYPO3\CMS\Redirects\Tests\Functional\Service\RedirectServiceTest\linkForRedirectToAccessRestrictedPageIsBuild(), TYPO3\CMS\Extbase\Tests\Unit\Persistence\Generic\Storage\Typo3DbBackendTest\overlayLanguageAndWorkspaceChangesUidIfInPreview(), TYPO3\CMS\Frontend\Tests\Unit\Controller\TypoScriptFrontendControllerTest\pageRendererLanguageIsSetToSiteLanguageTypo3LanguageInConstructor(), TYPO3\CMS\Core\Tests\Functional\Page\PageRendererTest\pageRendererRendersFooterValues(), TYPO3\CMS\Core\Tests\Functional\Page\PageRendererTest\pageRendererRendersFooterValuesDataProvider(), TYPO3\CMS\Extbase\Tests\Unit\Service\ImageScriptServiceTest\prefixIsCorrectlyAppliedToGetImageUri(), TYPO3\CMS\Extbase\Tests\Unit\Service\ImageScriptServiceTest\prefixIsCorrectlyAppliedToGetImageUriWithForcedAbsoluteUrl(), TYPO3\CMS\Extbase\Tests\Unit\Persistence\Generic\Storage\Typo3DbQueryParserTest\respectEnableFieldsSettingGeneratesCorrectStatement(), TYPO3\CMS\Extbase\Tests\Functional\Service\ExtensionServiceTest\setUp(), TYPO3\CMS\Frontend\Tests\Functional\Configuration\TypoScript\ConditionMatching\ConditionMatcherTest\setUp(), TYPO3\CMS\Frontend\Tests\Unit\ContentObject\Menu\AbstractMenuContentObjectTest\setUp(), TYPO3\CMS\Extbase\Tests\Functional\Persistence\QueryLocalizedDataTest\setUpBasicFrontendEnvironment(), TYPO3\CMS\Extbase\Tests\Functional\Persistence\TranslationTest\setUpBasicFrontendEnvironment(), TYPO3\CMS\FrontendLogin\Tests\Unit\Validation\RedirectUrlValidatorTest\setUpFakeSitePathAndHost(), TYPO3\CMS\Extbase\Tests\Functional\Persistence\WorkspaceTest\setupSubjectInBackend(), TYPO3\CMS\Extbase\Tests\Functional\Persistence\WorkspaceTest\setupSubjectInFrontend(), TYPO3\CMS\Extbase\Tests\Functional\Mvc\Web\RequestBuilderTest\silentlyIgnoreInvalidParameterAndUseDefaultAction(), TYPO3\CMS\Extbase\Tests\Unit\Persistence\Generic\Storage\Typo3DbBackendTest\uidOfAlreadyPersistedValueObjectIsDeterminedCorrectly(), TYPO3\CMS\Extbase\Tests\Unit\Persistence\Generic\Storage\Typo3DbQueryParserTest\visibilityConstraintStatementGenerationThrowsExceptionIfTheQuerySettingsAreInconsistent(), and TYPO3\CMS\Extbase\Tests\Unit\Persistence\Generic\Storage\Typo3DbQueryParserTest\visibilityConstraintStatementIsGeneratedAccordingToTheQuerySettings().

◆ REQUESTTYPE_INSTALL

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