In the default folder structure for a Symfony2 project the database and mail server credentials are stored in parameters.yml
file inside ProjectRoot/app/config/parameters.yml
with these default values:
parameters:
database_driver: pdo_mysql
database_host: 127.0.0.1
database_port: null
database_name: symfony
database_user: root
database_password: null
mailer_transport: smtp
mailer_host: 127.0.0.1
mailer_user: null
mailer_password: null
locale: en
secret: ThisTokenIsNotSoSecretChangeIt
During development we change these parameters to the development database and mail servers. This file is checked into the source code repository.
The problem is when we want to deploy to the production server. We are thinking about automating the deployment process by checking out the project from git and deploy it to the production server.
The thing is that our project manager has to manually update these parameters after each update. The production database and mail servers parameters are confidential and only our project manager knows them.
I need a way to automate this step and suggestion on where to store the production parameters until they are applied?
5
Rename parameters.yml
to parameters.yml.sample
, and ignore parameters.yml
in your version control.
For each installation of the app, copy .sample
back to the proper location and edit the details as needed.
That way you have a sample file that says what kind of details (mailer, DB, API keys, etc.) each installation needs, and the secrets are never in version control.
4
For production files you should not be using a file. A much better way that does not interfere with development practices (using the files) is to use ENV variables for your production environment.
Look at the cookbook for reference on this practice:
http://symfony.com/doc/current/cookbook/configuration/external_parameters.html
5