TYPO3 symfony console command: where to put/get configuration settings?

465 views Asked by At

I wrote a symfony console command for downloading CSV files from a remote server and importing data from those files into some database tables of my extension. This works fine so far (run from CLI or scheduler).

But to do all this, I need a bunch of configuration settings (credentials for the remote server, list of files to download, storagePid etc.) and I don't know where to put them. For the time being, it's all hardcoded, which is obviously bad. Of course I can just invent my own config file, put it somewhere sensible and include it in my code. But that seems messy and arbitrary.

Is there a recommended/best practice way to store such configuration settings? Ideally, I want them to be in my site package. For FE plugins we have Typoscript settings + constants and we can use similar mechanisms for BE modules. But what's the best strategy for this kind of CLI context?

1

There are 1 answers

8
Florian Rival On

I think that you can used Extension configuration (ext_conf_template.txt), you can set all the configuration there and it can be accessed through the scheduler as well as CLI I guess, using this API :

$extensionConfiguration = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(ExtensionConfiguration::class)->get('my_extension_key');

You can find more information here : Extension configuration

And in your command class, you can use the function Command::configure() in order to initialize the command configuration.

See : Symfony Console Command