ext_localconf.php
-- optional
ext_
is always included in global scope of the script,
in the frontend, backend and CLI context.
It should contain additional configuration of $GLOBALS
.
This file contains hook definitions and plugin configuration. It must not contain a PHP encoding declaration.
All ext_
files of loaded extensions are
included right after the files config/
and config/
during TYPO3
bootstrap.
Pay attention to the rules for the contents of these files. For more details, see the section below.
Should not be used for
While you can put functions and classes into ext_
,
it considered bad practice because such classes and functions would always be
loaded. Move such functionality to services or utility classes instead.
Registering hooks, XCLASSes or any simple array assignments to
$GLOBALS
options will not work for the following:
- class loader
- package manager
- cache manager
- configuration manager
- log manager (= Logging Framework)
- time zone
- memory limit
- locales
- stream wrapper
- error handler
- Icon registration. Icons should be registered in Icons.php.
This would not work because the extension files ext_
are
included (load
) after the creation of the
mentioned objects in the Bootstrap class.
In most cases, these assignments should be placed in
config/
.
Example:
Register an exception handler:
$GLOBALS['TYPO3_CONF_VARS']['SYS']['debugExceptionHandler'] =
\Vendor\Ext\Error\PostExceptionsOnTwitter::class;
Should be used for
These are the typical functions that extension authors should place within
file:ext_
- Registering hooks, XCLASSes
or any simple array assignments to
$GLOBALS
options['TYPO3_ CONF_ VARS'] - Registering additional Request Handlers within the Bootstrap
- Adding default TypoScript via
\TYPO3\
APIsCMS\ Core\ Utility\ Extension Management Utility - Registering Scheduler Tasks
- Adding reports to the reports module
- Registering Services via the Service API
Examples
Put a file called ext_
in the main directory of your
Extension. It does not need to be registered anywhere but will be loaded
automatically as soon as the extension is installed.
The skeleton of the ext_
looks like this:
<?php
declare(strict_types=1);
use MyVendor\MyExtension\MyClass;
defined('TYPO3') or die();
// Add your code here
MyClass::doSomething();