8

How to setup a different configuration parameters file for each environment?

At the moment parameters in parameters.yml are used in both dev and prod environment, but I need different parameters in order to deploy my app in prod.

gp_sflover
  • 3,460
  • 5
  • 38
  • 48
user3174311
  • 1,714
  • 5
  • 28
  • 66

1 Answers1

12

You can put all the parameters used in your dev environment in a app\config\parameters_dev.yml file (you need to create it) and then import it in your app\config\config_dev.yml:

imports:
    - { resource: config.yml }
    - { resource: parameters_dev.yml }

So when you work in local any parameter used in production will be overwritten by the new file with the right parameters.

And remember to Clear the cache!

gp_sflover
  • 3,460
  • 5
  • 38
  • 48
  • ok I did this way, so I expect that using app.php it should use parameters in parameters.yml, and using app_dev.php it should use parameters in parameters_dev.yml. looks like the only file used is parameters_dev is used from both front controllers... – user3174311 Mar 29 '15 at 11:17
  • 3
    ARGH! DAMN CACHE! now works perfectly. I love you. thank you. – user3174311 Mar 29 '15 at 11:21
  • 1
    @user3174311 I use this type of configuration every time. In production will be only used parameters in `parameters.yml` as well as for others environments. For example you may want to have your database mirrored for testing purposes (and with different access data) and for this just create a `parameters_test.yml` and apply the same concept. – gp_sflover Mar 29 '15 at 11:25