is it better to store platform configuration in database or a file?

Viewed 31746

currently we are developing an app in which we use database table to store platform settings, like maximum file size, maximum users number, support email, etc.

it means that each time we add a platform setting we have to add a column to this table.

in my previous projects i am used to store such information in file.

what is better/faster approach?

ps, i am almost sure someone already had such question, but i can't seem to find it

6 Answers

I think like everyone said, depends on your application environment and requirements. But if I had to pick a general rule, I'd say BOTH. First, you create a database table to store all your configurations. This is good for two reasons: 1) Versioning - allows you to easily keep track of previous configurations. 2) Management - You can create an interface that your users can access to change settings.

Secondly, you create a file that after you saved and published the site to production, it will also save all those settings into a file that will be easily accessed. In fact, if you are programming in PHP for the web, that file should be a php file with array data (key-value pairs) that need no further manipulation. By this I mean, no need to convert your yaml, or json into array if that is the final output you need to have.

Related