Take the 2-minute tour ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free, no registration required.

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?

share|improve this question
    
"I need a way to automate this step." phing.info –  Yannis Rizos Oct 30 '13 at 12:39
    
@YannisRizos yup, but what should I do exactly with Phing? Do we store the database credentials in a file then copy them? where should that file be? better idea than a file? –  Songo Oct 30 '13 at 12:41
    
Most frameworks have the idea of environments. You can load a different config for test, production, development, etc... –  Mike Oct 30 '13 at 12:42
    
The simplest (and crudest) solution would be to tell phing to replace your local credentials with the production ones, when you're building for production. That said, as @Mike already mentioned, setting up different configurations per environment is also a good idea (see: symfony.com/doc/current/cookbook/configuration/…). Mike, you should probably expand that comment to an answer. –  Yannis Rizos Oct 30 '13 at 12:45
    

1 Answer 1

up vote 1 down vote accepted

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.

share|improve this answer
    
so basically I upload a file with the production parameters to the production server and after each check out I copy it into the project? –  Songo Oct 30 '13 at 13:53
    
Yep. Or automate it. –  Amy B Oct 30 '13 at 16:16
    
This doesn't answer the last part of the question: I need a way to automate this step and suggestion on where to store the production parameters until they are applied? I only point it out because I'm curious since I'll be dealing with this soon myself. –  bstempi Oct 31 '13 at 4:03
    
You can automate your deployment process in a thousand ways -- bash scripts, Ruby scripts, Chef... Where to store the params until they are applied? A secure file on a server that all your production servers can read from? On paper? –  Amy B Oct 31 '13 at 8:48

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.