Sigala's Blog

How to get Typoscript settings in PHP files outside of Exbase in the frontend context

Published

In this post, I will be showing you how to get or access your Typoscript settings in PHP files in your extension which are not in the Exbase context. That is PHP files like middlewares, services and utility files and others.

Accessing the Typoscript settings in Controllers is easy as you can just use the $this->settings property which is readily available in all Extbase controllers.

 

Code Snippets

 

plugin.tx_myextension {
   settings {
      storagePid = 25
   }
}

 

Asuming you have the Typoscript configuration above in an extension, and you want to get the value of the storagePid setting, use the code below.

myextension is the name of your extension without underscores.

 

$configurationManager = GeneralUtility::makeInstance(ConfigurationManager::class);
$typoscriptSettings = $configurationManager->getConfiguration(ConfigurationManagerInterface::CONFIGURATION_TYPE_FULL_TYPOSCRIPT);
$extensionSettings = $typoscriptSettings['plugin.']['tx_myextension.']['settings.'];

$storagePid = $extensionSettings['storagePid'];

 

 

That's it for this post, any questions just write to me via the Contact form or Slack(mbigha)