Fulgurio

Make a better web

B.A.-BA of developer : the config file

May be you will find that this post is a little bit stupid, but I’ve been confronted several times with this kind of mistake, and I think it’s interesting to explain why it is a mistake.

Usually in yours developments, you have to store informations which are different in each environment. For example, informations access to the database in a production environment will be need to be different from the development environment.
This information is stored in the source code, and must be ABSOLUTELY grouped in a single file.

Why? Imagine that each developers put in its own code his own parameters. This works fine on development environment, but not on the other environments. One must look at the parameters in the code and modify it to make it work on its environment. In short, we can spend time there.

Worse, when deploying the website, you will probably not be the person who will deploy the website. The third person will be advised of the location of each parameter. Ok, the deployment takes place only one time, but what about evolution ? One might be lead to deliveran evolution, and during deployment, not possible to make the site offline for the setting of new files.

The majority of tools (if not all) uses a configuration file where you find all these parameters. So just edit a single file for the site is functional in a new environment, like config.php.

So please, use one single file to put all parameters of your project ! Thinks for the other guy who will use your code !

Further, the best is to have a parameter file for production and a second file for development environement,and to have a script that loads the correct file depending on the environment. That way, no cold sweats in the crash of all files. This will be the subject of next post.

Tags:

Leave a Reply

(*) required
*
*