Reading configuration outside a frontend request 

Extbase settings are only available while Extbase dispatches a plugin or a backend module, see Accessing settings outside a controller. Code that runs anywhere else reads its configuration from a source that exists in its context.

Frontend TypoScript outside the frontend 

In backend contexts (such as backend modules,) CLI commands, or scheduler tasks, frontend TypoScript is either not loaded or behaves unpredictably. Backend requests lack an active frontend user session and page context, while handling record visibility flags such as starttime , endtime , hidden , and workspace overlays differently. Attempting to evaluate frontend TypoScript in the backend triggers unnecessary overhead and leads to unreliable results.

Global configuration: use site settings 

If a configuration value does not belong to a specific content element or plugin instance, but applies globally to a site or extension (for example, API keys, external endpoint URLs, or global defaults), Extbase TypoScript settings are usually not the best place for it.

Instead, use site settings. Site settings can be retrieved in any service, middleware, or console command using the Site object:

Reading a site setting
$apiKey = $site->getSettings()->get('myExtension.apiKey');
Copied!

The site object can be obtained from the PSR-7 request ( $request->getAttribute('site') ) or by injecting SiteFinder . See Accessing site settings in PHP and Fluid for details.

This requires knowing which site to load. In a frontend request the site has already been resolved. Without one, SiteFinder needs a site identifier or a page uid to find the site. When neither is known, or when a value is the same for every site, other sources fit better:

  • TypoScript remains a valid place for such values. Without the Extbase configuration manager, it can be read in a frontend request through the frontend.typoscript request attribute, once the frontend has prepared it. getFlatSettings() returns the TypoScript constants and is always available there. getSetupArray() returns the setup, but throws an exception on a page delivered from the page cache. Outside a frontend request, TypoScript is not built for the request.
  • The extension configuration needs no request, no site and no page, see Installation-wide configuration: use extension configuration.

Installation-wide configuration: use extension configuration 

A value that is the same for every site, or that is needed where no site is known, belongs in the extension configuration. \TYPO3\CMS\Core\Configuration\ExtensionConfiguration reads it without a request, a site or a page:

Reading an extension configuration value
$newRecordPid = (int)$extensionConfiguration->get('my_extension', 'newRecordPid');
Copied!

Administrators set these values in System > Settings. The conferences backend module uses one for the page it creates new records on, see Creating records from an Extbase backend module.