How do you decide what you put in your configuration file and your database

Does anyone have a good system for deciding what to put into the database and what to add to the configuration file.

My config file is a php array and I have a mysql database.

If, for example, I have a 5-row data set that rarely changes (if ever), is it better to save it in the configuration file?

I am looking for a rule in which I can follow that will help me choose - if anyone has it.

+4
source share
5 answers

It really depends on the data. The configuration file is really used for specific applications, while your database should contain data that your application will use to achieve its goal.

+2
source

In the configuration file, specify everything that can be changed by the developer / user of your project / structure. As a rule, it stores wide variables and site constants.

Use a database for things that should not be modified by users of your infrastructure, for example.

+1
source

One rule that I always use:

If the user (including the administrator role) ever needs to change it, put it in the database.

+1
source

This is a preferable question than anything else.

I agree more with the rule if the configuration information is static (relatively) or rarely changing, then paste it into a flat file in a protected area to enable it.

For different configuration parameters that may change or may require owners of places with variable places, I would save them in a database.

Using your 5 line example. I would stick with a flat file.

0
source

Sometimes the decision is based on what resource you will have access to changes in production. Depending on the size and complexity of your organization, receiving changes made to the production configuration file may require several levels of management approval and hours (if not days) of delays. Although modifying the prod database (albeit a custom-made application) can be relatively simple.

This special database application can also be useful so that users (or admin users) can modify the data.

Another consideration is whether you want to restart the application when data changes. Sometimes changing the configuration file may cause a restart - it depends on the web server, etc. If you want to be able to change on the fly, without restarting the application, the database is the place to store data.

0
source

All Articles