TYPO3 provides an API class for creating so-called ‘feature toggles’. Feature toggles provide an easy way to add new implementations of features next to their legacy version. By using a feature toggle, the integrator or site admin can decide when to switch to the new feature.
The API checks against a system-wide option array within
$GLOBALS['TYPO3_CONF_VARS']['SYS']['features'] which an integrator
or admin can set in the
Both TYPO3 Core and Extensions can provide alternative functionality for a certain feature.
Examples for features are:
- Throw exceptions in new code instead of just returning a string message as error message.
- Disable obsolete functionality which might still be used, but slows down the system.
- Enable alternative PageNotFound handling for an installation.
Naming of feature toggles¶
Feature names should NEVER be named “enable” or have a negation, or contain versions or years.
It is recommended to use
lowerCamelCase notation for the feature names.
Core feature toggles¶
Some examples for feature toggles in the TYPO3 Core:
redirects.hitCount: Enables hit statistics in the redirects backend module
typoScript.strictSyntax: If on, TypoScript is parsed in strict syntax modes. Enabling this feature means old condition syntax (which is deprecated) will trigger deprecation messages.
Enable / disable feature toggle¶
Features can be toggled in the Settings module via Feature Toggles:
Internally, the changes are written to
'SYS' => [ 'features' => [ 'redirects.hitCount' => true, ], ]
Feature toggles in TypoScript¶
To check whether a feature is enabled in TypoScript was introduced in v9.5 in Issue #86881
Support for feature toggle check in the symfony expression language DefaultFunctionProvider is provided.
With the new function
feature() the feature toggle can be checked.
[feature("unifiedPageTranslationHandling")] # This condition matches if the feature toggle "unifiedPageTranslationHandling" is true [END] [feature("unifiedPageTranslationHandling") === false] # This condition matches if the feature toggle "unifiedPageTranslationHandling" is false [END]