ext_localconf.php are the two
most important files for the execution of extensions
within TYPO3. They contain configuration used by the system on almost
every request. They should therefore be optimized for speed.
ext_localconf.phpis always included in global scope of the script, either frontend or backend.
While you can put functions and classes into the script, it is a really bad practice because such classes and functions would always be loaded. It is better to have them included only as needed.
So stick to changing values in
ext_tables.phpis not always included in global scope (in the frontend)
It should still not contain functions and classes as it still very often loaded.
Use the API of class
extMgmfor tasks such as adding tables, merging information into arrays, etc.
Before the inclusion of any of the two files, the variables
$_EXTKEYis set to the extension key and
$_EXTCONFis set to the configuration from
$TYPO3_LOADED_EXT[extension key]contains information about whether the module is loaded as local, global or system type, including the proper paths you might use, absolute and relative.
The inclusion can happen in two ways:
- Either the files are included individually on each request (many file
- or (better) the files are automatically imploded into one single
temporary file (cached) in
typo3conf/directory (only one file include) (
$TYPO3_CONF_VARS["EXT"]["extCache"]=1;). This is default.
In effect this means:
ext_localconf.phpfile must be designed so that they can safely be read and subsequently imploded into one single file with all the other configuration scripts!
- You must never use a “return” statement in the files global scope - that would make the cached script concept break.
- You should not rely on the PHP constant
__FILE__for detection of include path of the script - the configuration might be executed from a cached script and therefore such information should be derived from the
$TYPO3_LOADED_EXT[extension key]array, e.g.
- Either the files are included individually on each request (many file includes) (