Production, development, configuration configuration in ZF2?

I read several guides on this subject, but still have not completely understood what is expected from a developer who wants to make a ZF2 application environment:

http://blog.evan.pro/environment-specific-configuration-in-zend-framework-2
http://www.spiffyjr.me/2012/06/17/how-does-configuration-work-in-zf2/comment-page-1/

ZF2 does not understand the concept of a design environment - it is left to the developer for implementation. I do not quite understand how this should be done ...

Reading through an Evan message it seems that there are 2 mechanisms - and it is preferable not to use APPLICATION_ENV constant , only .local, .global files?

How should this work? Can someone describe the process they are doing to inform the environment of ZF2? And what do you do when the code needs to be ported to another environment?


It seems like the idea now is to: exe: module1.local.php.dist-testing , module1.local.php.dist-production , module1.local.php.dist-development , and when the code moves to another environment , the idea is that they should be renamed for this environment and passwords filled in manually? Am I right?

+4
source share
1 answer

The idea is that you provide your reasonable default configuration in your application, but you do not store anything for a specific environment with your code or in your version control system.

If you have, for example, two servers, one for production, one for development, you only provide configuration data for one environment in such a .local file. Thus, your development server cannot know, for example. master password for the production database. Therefore, it doesn’t happen by chance that you get a new development server, and someone forgets to set APPLICATION_ENV, and you start developing and messing up your production database because the application knows the passwords.

Or vice versa, a new production server cannot accidentally access a development database.

Thus, your application will automatically know about the environment by reading the file that is present, and there is only one file for each environment in which there are all the details.

This puts the burden of ensuring the correctness of the file to the administrator - or to a puppet script that configures everything. But the environment-specific configuration will not be deployed in the application.

+7
source

All Articles