Skip to content

Configuring extensions from within your site setup

Configuring extensions via Install Tool - nowadays - can be cumbersome. Especially if this needs to be repeated several times for some reason. This article shows a possibility to centrally configure all extensions from within your own site setup's ext_localconf.php

There are some ever-repeating tasks one has to accomplish when setting up new TYPO3 instances. One thing we always do is to disable the scheduler's sample tasks, for instance. This has to be configured in the extension configuration of the scheduler extension in the Install Tool.

Doing such configurations over and over again is a boring thing, so we introduced the habbit to have also this configuration centralized in our main "site setup" (or "site package" how some like to call it). The nice benefit is that this configuration is now also under version control as our site setup usually is.

The basic idea is to evaluate one specific setting of each extension in the ext_localconf.php file and if it does not match the intended value all configuration for the affected extension is updated in the LocalConfiguration.php.

The basic code inside ext_localconf.php can look like this:

$extensionConfiguration = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\TYPO3\CMS\Core\Configuration\ExtensionConfiguration::class);

$schedulerConfig = $extensionConfiguration->get('scheduler');
if ($schedulerConfig['showSampleTasks']) {
    $extensionConfiguration->set('scheduler', 'showSampleTasks', 0);
}

Another example would be to set the backend styling how you like it:

$logo = 'EXT:' . $extKey . '/Resources/Public/Images/logo.png';
$beImage = 'EXT:' . $extKey . '/Resources/Public/Images/belogin_background.jpg';
$backendConfig = $extensionConfiguration->get('backend');
if ($backendConfig['loginLogo'] !== $logo) {
    $extensionConfiguration->set('backend', 'loginLogo', $logo);
    $extensionConfiguration->set('backend', 'loginBackgroundImage', $beImage);
}

 

This information applies to TYPO3 9 LTS