codeigniter4/settings

Overriding values in Config/App.php

clsmedia opened this issue · 2 comments

Could you please give me a hint how to use Settings to store values from Config/App.php? For example we have $defaultLocale = 'en' defined in the file, but in the database I have
settings(id, class, key, value, created_at, updated_at) VALUES ('1', 'Config/App', 'defaultLocale', 'en', '2022-04-15 08:39:25', '2022-04-15 06:42:47'.

Should the values from the database automatically override the value from Config/App.php? Do I need to somehow manipulate the framework to use the values from the database for $dafaultLocale?

I ask because overriding the value from the database does not change the language in the framework (manually changing it in Config/App.php obviously works fine).

Settings can work with Config\App just like any other config file when used in your own code:

$locale = setting('App.defaultLocale');

However, the framework itself doesn't use setting so anything in the core would not take advantage of this. Either you'd need to create something in BaseController or maybe within a Filter to check your setting and store it locally.

Thank you very much