Load different Database Symfony2

How can I load different database for production and development environment ?

In parameters.yml I have the main database configuration, but I don’t know how to add the dev database with differets parameters.

I’m looking for this on Google but I can’t find any help.

Maybe with config_dev.yml and config_prod.yml? but I’m not sure how to do that.

Any help would be appreciated. Thanks.

Answer

I will do something like this:

Files hierarchy: 1) parameters.yml – for common parameters 2) create parameters_dev.yml – only dev db connection params 3) create parameters_prod.yml – only prod db connection params

In head of config files: 1) config.yml

imports:
    - { resource: parameters.yml }

2) config_dev.yml

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

3) config_prod.yml

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

Leave a Reply

Your email address will not be published. Required fields are marked *