Working with Settings.yaml

Sometimes you need a couple of configuration parameters for your project. In TYPO3 most of this settings are done via flexforms or TypoScript settings.

In FLOW3 there is a file called Settings.yaml. There you can add your settings for your project. There are also different contexts available. So you can add the Settings.yaml file directly in the configuration folder, or you choose a sub folder. Available contexts are Development, Production and Testing. Making usage of the different contexts makes a lot of sense if you want to deploy your project from development to production and if you have different settings for development and production.

For example, on my project I use OAuth for the connection to twitter. So I set the credentials for twitter in my Settings.yaml file and I have different credentials for development and production. Since the context is set in my vhost configuration, I don’t have to take care of switching this. As soon as my files are on the live server, FLOW3 is automatically picking the right settings in dependency of the current context.

For this example we put the Settings.yaml in the root of the configuration folder and just add the lines below.

Inject the settings

To make the settings available in our controller we add a injectSettings function and set the settings.

After that the settings are available in our $this->settings array.

In our indexAction you can see how to access the settings and use them.

 Using the settings in Fluid

If you just want to use the settings in your Fluid template, you don’t have to inject or assign the settings to you view. You can just access them via Fluid using {settings.youSetting}