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

Public Member Functions

 getRequestId ()
 
 getApplicationContext ()
 
 startOutputBuffering ()
 
 configure ()
 
 baseSetup ($entryPointLevel=0)
 
 initializeClassLoader ($classLoader)
 
 checkIfEssentialConfigurationExists ()
 
 redirectToInstallTool ($entryPointLevel=0)
 
 registerRequestHandlerImplementation ($requestHandler)
 
 handleRequest ($request)
 
 setEarlyInstance ($objectName, $instance)
 
 getEarlyInstance ($objectName)
 
 getEarlyInstances ()
 
 loadConfigurationAndInitialize ($allowCaching=true, $packageManagerClassName=\TYPO3\CMS\Core\Package\PackageManager::class)
 
 ensureClassLoadingInformationExists ()
 
 loadTypo3LoadedExtAndExtLocalconf ($allowCaching=true)
 
 populateLocalConfiguration ()
 
 disableCoreCache ()
 
 initializeCachingFramework ()
 
 setRequestType ($requestType)
 
 setFinalCachingFrameworkCacheConfiguration ()
 
 defineLoggingAndExceptionConstants ()
 
 unsetReservedGlobalVariables ()
 
 checkLockedBackendAndRedirectOrDie ($forceProceeding=false)
 
 checkBackendIpOrDie ()
 
 checkSslBackendAndRedirectIfNeeded ()
 
 loadExtensionTables ($allowCaching=true)
 
 initializeBackendAuthentication ($proceedIfNoUserIsLoggedIn=false)
 
 endOutputBufferingAndCleanPreviousOutput ()
 
 initializeOutputCompression ()
 
 sendHttpHeaders ()
 
 shutdown ()
 
 initializeBackendTemplate ()
 

Static Public Member Functions

static usesComposerClassLoading ()
 
static getInstance ()
 

Protected Member Functions

 __construct ($applicationContext)
 
 __clone ()
 
 sendResponse ()
 
 defineUserAgentConstant ()
 
 registerExtDirectComponents ()
 
 setCacheHashOptions ()
 
 setDefaultTimezone ()
 
 initializeL10nLocales ()
 
 initializeErrorHandling ()
 
 setMemoryLimit ()
 
 defineTypo3RequestTypes ()
 

Protected Attributes

 $requestId
 
 $applicationContext
 
 $earlyInstances = []
 
 $installToolPath
 
 $availableRequestHandlers = []
 
 $response
 

Static Protected Attributes

static $instance = null
 
static $usesComposerClassLoading = false
 

Detailed Description

This class encapsulates bootstrap related methods. It is required directly as the very first thing in entry scripts and used to define all base things like constants and pathes and so on.

Most methods in this class have dependencies to each other. They can not be called in arbitrary order. The methods are ordered top down, so a method at the beginning has lower dependencies than a method further down. Do not fiddle with the load order in own scripts except you know exactly what you are doing!

Definition at line 32 of file core/Classes/Core/Bootstrap.php.

Constructor & Destructor Documentation

__construct (   $applicationContext)
protected

Definition at line 87 of file core/Classes/Core/Bootstrap.php.

References Bootstrap\$applicationContext.

Member Function Documentation

__clone ( )
protected

Disable direct cloning of this object.

Definition at line 104 of file core/Classes/Core/Bootstrap.php.

baseSetup (   $entryPointLevel = 0)

Run the base setup that checks server environment, determines pathes, populates base files and sets common configuration.

Script execution will be aborted if something fails here.

Parameters
int$entryPointLevelNumber of subdirectories where the entry script is located under the document root
Returns
Bootstrap
Exceptions
RuntimeException when TYPO3_REQUESTTYPE was not set before, setRequestType() needs to be called before

Definition at line 192 of file core/Classes/Core/Bootstrap.php.

References ClassLoadingInformation\isClassLoadingInformationAvailable(), GeneralUtility\presetApplicationContext(), ClassLoadingInformation\registerClassLoadingInformation(), and SystemEnvironmentBuilder\run().

checkBackendIpOrDie ( )

Compare client IP with IPmaskList and exit the script run if the client is not allowed to access the backend

Returns
Bootstrap

Definition at line 877 of file core/Classes/Core/Bootstrap.php.

References $GLOBALS, GeneralUtility\cmpIP(), and GeneralUtility\getIndpEnv().

checkIfEssentialConfigurationExists ( )

checks if LocalConfiguration.php or PackageStates.php is missing, used to see if a redirect to the install tool is needed

Returns
bool TRUE when the essential configuration is available, otherwise FALSE

Definition at line 228 of file core/Classes/Core/Bootstrap.php.

References Bootstrap\setEarlyInstance().

checkLockedBackendAndRedirectOrDie (   $forceProceeding = false)

Check adminOnly configuration variable and redirects to an URL in file typo3conf/LOCK_BACKEND or exit the script

Exceptions
RuntimeException
Parameters
bool$forceProceedingif this option is set, the bootstrap will proceed even if the user is logged in (usually only needed for special AJAX cases, see AjaxRequestHandler)
Returns
Bootstrap

Definition at line 852 of file core/Classes/Core/Bootstrap.php.

References $GLOBALS.

checkSslBackendAndRedirectIfNeeded ( )

Check lockSSL configuration variable and redirect to https version of the backend if needed

Returns
Bootstrap

Definition at line 895 of file core/Classes/Core/Bootstrap.php.

References $GLOBALS, and GeneralUtility\getIndpEnv().

configure ( )

Main entry point called at every request usually from Global scope. Checks if everything is correct, and loads the Configuration.

Make sure that the baseSetup() is called before and the class loader is present

Returns
Bootstrap

Definition at line 168 of file core/Classes/Core/Bootstrap.php.

References Bootstrap\startOutputBuffering().

defineLoggingAndExceptionConstants ( )

Define logging and exception constants

Returns
Bootstrap

Definition at line 743 of file core/Classes/Core/Bootstrap.php.

References $GLOBALS.

defineTypo3RequestTypes ( )
protected

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.

Returns
Bootstrap

Definition at line 700 of file core/Classes/Core/Bootstrap.php.

defineUserAgentConstant ( )
protected

Define user agent constant

Returns

Definition at line 521 of file core/Classes/Core/Bootstrap.php.

References $GLOBALS.

disableCoreCache ( )

Set cache_core to null backend, effectively disabling eg. the cache for ext_localconf and PackageManager etc.

Returns

Definition at line 508 of file core/Classes/Core/Bootstrap.php.

References $GLOBALS.

Referenced by Bootstrap\loadConfigurationAndInitialize().

endOutputBufferingAndCleanPreviousOutput ( )

Throw away all output that may have happened during bootstrapping by weird extensions

Returns
Bootstrap

Definition at line 1062 of file core/Classes/Core/Bootstrap.php.

ensureClassLoadingInformationExists ( )
getApplicationContext ( )

Returns the application context this bootstrap was started in.

Returns
The application context encapsulated in an object

Definition at line 142 of file core/Classes/Core/Bootstrap.php.

References Bootstrap\$applicationContext.

getEarlyInstance (   $objectName)

Returns an instance which was registered earlier through setEarlyInstance()

Parameters
string$objectNameObject name of the registered instance
Returns
object
Exceptions
TYPO3

Definition at line 362 of file core/Classes/Core/Bootstrap.php.

Referenced by Bootstrap\populateLocalConfiguration(), and Bootstrap\setFinalCachingFrameworkCacheConfiguration().

getEarlyInstances ( )

Returns all registered early instances indexed by object name

Returns
array

Definition at line 376 of file core/Classes/Core/Bootstrap.php.

References Bootstrap\$earlyInstances.

getRequestId ( )

Gets the request's unique ID

Returns
string Unique request ID

Definition at line 130 of file core/Classes/Core/Bootstrap.php.

References Bootstrap\$requestId.

handleRequest (   $request)

Builds a Request instance from the current process, and then resolves the request through the request handlers depending on Frontend, Backend, CLI etc.

Parameters
\Psr\Http\Message\RequestInterface | \Symfony\Component\Console\Input\InputInterface$request
Returns
Bootstrap
Exceptions
TYPO3
TYPO3 Is thrown if the response object defined an exit code > 0
Returns
string

Definition at line 304 of file core/Classes/Core/Bootstrap.php.

initializeBackendAuthentication (   $proceedIfNoUserIsLoggedIn = false)

Initializes and ensures authenticated access

Definition at line 1036 of file core/Classes/Core/Bootstrap.php.

References $GLOBALS.

initializeBackendTemplate ( )

Provides an instance of "template" for backend-modules to work with.

Returns
Bootstrap

Definition at line 1122 of file core/Classes/Core/Bootstrap.php.

References $GLOBALS, and GeneralUtility\makeInstance().

initializeCachingFramework ( )

Initialize caching framework, and re-initializes it (e.g. in the install tool) by recreating the instances again despite the Singleton instance

Returns
Bootstrap

Definition at line 562 of file core/Classes/Core/Bootstrap.php.

References $GLOBALS, Bootstrap\setEarlyInstance(), and GeneralUtility\setSingletonInstance().

Referenced by Bootstrap\loadConfigurationAndInitialize().

initializeClassLoader (   $classLoader)

Sets the class loader to the bootstrap

Parameters
\Composer\Autoload\ClassLoader$classLoaderan instance of the class loader
Returns
Bootstrap

Definition at line 212 of file core/Classes/Core/Bootstrap.php.

References Bootstrap\setEarlyInstance().

initializeErrorHandling ( )
protected

Configure and set up exception and error handling

Returns
Bootstrap
Exceptions
RuntimeException

Definition at line 631 of file core/Classes/Core/Bootstrap.php.

References $GLOBALS, GeneralUtility\cmpIP(), GeneralUtility\getIndpEnv(), and GeneralUtility\makeInstance().

initializeL10nLocales ( )
protected

Initialize the locales handled by TYPO3

Returns
Bootstrap

Definition at line 619 of file core/Classes/Core/Bootstrap.php.

initializeOutputCompression ( )

Initialize output compression if configured

Returns
Bootstrap

Definition at line 1074 of file core/Classes/Core/Bootstrap.php.

References $GLOBALS, and MathUtility\canBeInterpretedAsInteger().

loadConfigurationAndInitialize (   $allowCaching = true,
  $packageManagerClassName = \TYPO3\CMS\Core\Package\PackageManager::class 
)

Includes LocalConfiguration.php and sets several global settings depending on configuration.

Parameters
bool$allowCachingWhether to allow caching - affects cache_core (autoloader)
string$packageManagerClassNameDefine an alternative package manager implementation (usually for the installer)
Returns
Bootstrap

Definition at line 390 of file core/Classes/Core/Bootstrap.php.

References Bootstrap\disableCoreCache(), Bootstrap\ensureClassLoadingInformationExists(), Bootstrap\initializeCachingFramework(), and Bootstrap\populateLocalConfiguration().

loadExtensionTables (   $allowCaching = true)

Load ext_tables and friends.

This will mainly set up $TCA and several other global arrays through API's like extMgm. Executes ext_tables.php files of loaded extensions or the according cache file if exists.

Parameters
bool$allowCachingTrue, if reading compiled ext_tables file from cache is allowed
Returns
Bootstrap

Definition at line 923 of file core/Classes/Core/Bootstrap.php.

loadTypo3LoadedExtAndExtLocalconf (   $allowCaching = true)

Load ext_localconf of extensions

Parameters
bool$allowCaching
Returns
Bootstrap

Definition at line 477 of file core/Classes/Core/Bootstrap.php.

populateLocalConfiguration ( )

We need an early instance of the configuration manager. Since makeInstance relies on the object configuration, we create it here with new instead.

Returns
Bootstrap

Definition at line 490 of file core/Classes/Core/Bootstrap.php.

References Bootstrap\getEarlyInstance(), and Bootstrap\setEarlyInstance().

Referenced by Bootstrap\loadConfigurationAndInitialize().

redirectToInstallTool (   $entryPointLevel = 0)

Redirect to install tool if LocalConfiguration.php is missing.

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

Definition at line 241 of file core/Classes/Core/Bootstrap.php.

registerExtDirectComponents ( )
protected

Register default ExtDirect components

Returns
Bootstrap

Definition at line 532 of file core/Classes/Core/Bootstrap.php.

References ExtensionManagementUtility\registerExtDirectComponent().

registerRequestHandlerImplementation (   $requestHandler)

Adds available request handlers usually done via an application from the outside.

Parameters
string$requestHandlerclass which implements the request handler interface
Returns
Bootstrap

Definition at line 258 of file core/Classes/Core/Bootstrap.php.

sendHttpHeaders ( )

Send HTTP headers if configured

Returns
Bootstrap

Definition at line 1091 of file core/Classes/Core/Bootstrap.php.

References $GLOBALS.

sendResponse ( )
protected

Outputs content if there is a proper Response object.

Returns
Bootstrap

Definition at line 319 of file core/Classes/Core/Bootstrap.php.

Referenced by Bootstrap\shutdown().

setCacheHashOptions ( )
protected

Set cacheHash options

Returns
Bootstrap

Definition at line 576 of file core/Classes/Core/Bootstrap.php.

References $GLOBALS, and GeneralUtility\trimExplode().

setDefaultTimezone ( )
protected

Set default timezone

Returns
Bootstrap

Definition at line 597 of file core/Classes/Core/Bootstrap.php.

References $GLOBALS.

setEarlyInstance (   $objectName,
  $instance 
)

Registers the instance of the specified object for an early boot stage. On finalizing the Object Manager initialization, all those instances will be transferred to the Object Manager's registry.

Parameters
string$objectNameObject name, as later used by the Object Manager
object$instanceThe instance to register
Returns
void

Definition at line 349 of file core/Classes/Core/Bootstrap.php.

References Bootstrap\$instance.

Referenced by Bootstrap\checkIfEssentialConfigurationExists(), Bootstrap\initializeCachingFramework(), Bootstrap\initializeClassLoader(), and Bootstrap\populateLocalConfiguration().

setFinalCachingFrameworkCacheConfiguration ( )

Extensions may register new caches, so we set the global cache array to the manager again at this point

Returns
Bootstrap

Definition at line 731 of file core/Classes/Core/Bootstrap.php.

References $GLOBALS, and Bootstrap\getEarlyInstance().

setMemoryLimit ( )
protected

Set PHP memory limit depending on value of $GLOBALS['TYPO3_CONF_VARS']['SYS']['setMemoryLimit']

Returns
Bootstrap

Definition at line 686 of file core/Classes/Core/Bootstrap.php.

References $GLOBALS.

setRequestType (   $requestType)

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

Exceptions
RuntimeException if the method was already called during a request
Returns
Bootstrap

Definition at line 715 of file core/Classes/Core/Bootstrap.php.

shutdown ( )

Things that should be performed to shut down the framework. This method is called in all important scripts for a clean shut down of the system.

Returns
Bootstrap

Definition at line 1109 of file core/Classes/Core/Bootstrap.php.

References Bootstrap\sendResponse().

startOutputBuffering ( )

Prevent any unwanted output that may corrupt AJAX/compression. This does not interfere with "die()" or "echo"+"exit()" messages!

Returns
Bootstrap

Definition at line 154 of file core/Classes/Core/Bootstrap.php.

Referenced by Bootstrap\configure().

unsetReservedGlobalVariables ( )

Unsetting reserved global variables: Those are set in "ext:core/ext_tables.php" file:

Returns
Bootstrap

Definition at line 758 of file core/Classes/Core/Bootstrap.php.

References $GLOBALS.

Member Data Documentation

$applicationContext
protected
$availableRequestHandlers = []
protected

Definition at line 67 of file core/Classes/Core/Bootstrap.php.

$earlyInstances = []
protected

Definition at line 56 of file core/Classes/Core/Bootstrap.php.

Referenced by Bootstrap\getEarlyInstances().

$installToolPath
protected

Definition at line 61 of file core/Classes/Core/Bootstrap.php.

$instance = null
staticprotected

Definition at line 37 of file core/Classes/Core/Bootstrap.php.

Referenced by Bootstrap\setEarlyInstance().

$requestId
protected

Definition at line 44 of file core/Classes/Core/Bootstrap.php.

Referenced by Bootstrap\getRequestId().

$response
protected

Definition at line 74 of file core/Classes/Core/Bootstrap.php.

$usesComposerClassLoading = false
staticprotected

Definition at line 79 of file core/Classes/Core/Bootstrap.php.