Identify database server (homologation and production) in two different environments

1

As in most cases, I have two environments: approval and production for both the server and the database.

I would like to know how to use the same database address in the application settings (in PHP) where, when being run in the homologation environment, the host points to the homologation bank, when in production, the host would point to the production database, thus avoiding setting the database host whenever the server was deployed.

    
asked by anonymous 04.08.2016 / 15:45

2 answers

0

The host is up to simple, you could point to your / etc / hosts for different addresses or use an "internal" DNS that solves for different names. But beyond the hosts, it has authentication credentials and other environment variables, it is recommended that the host be configurable, as well as the rest.

    
06.08.2016 / 19:02
0

If your goal is to not have to change the code between approval and production, my suggestion is to follow the configuration guidelines in 12 Factor App .

Have your application read the host name (and port, bank name, login, password) of an environment variable. In each environment you configure the variables however you want and your code does not need to be touched: the same one that ran in type approval will run in production.

    
08.09.2016 / 18:19