danyal14
danyal14

Reputation: 367

Symfony3 environment base settings

I am using Symfony3 for quite while now. Today I am at the point where I need to store different api hosts per environment.

Like:

Development
Staging
Production

I tried to put these settings in config.ymal, but symfony faild to parse it.

Any suggestions?

Thanks in Advance.

Danyal

Upvotes: 0

Views: 103

Answers (3)

DevDonkey
DevDonkey

Reputation: 4880

either of the above answers are fine.

But another approach would be to have a parameters.yml file per server install, and have the server dependent settings in there. This is how symfony ships.

It avoids the need to have separate front end controllers set up which I prefer as it keeps things simple.

Make sure parameters.yml is added to .gitIgnore, and also make sure that the parameters.yml.dist file contains the same entries in it (or delete the fine entirely), otherwise when you run composer it'll delete any entries that don't match it.

Upvotes: 1

Bobo
Bobo

Reputation: 462

Create a new file like for exemple config_stagging.yml and add

imports:
    - { resource: config.yml }

Add scpecific configuration you want inside the file

Copy app_dev.php to app_stagging.php

Change line $kernel = new AppKernel('dev', true); to $kernel = new AppKernel('stagging', true);

Execut command : php bin/console cache:clear

In your url inside to use app_dev, use app_stagging

Upvotes: 1

ahammar
ahammar

Reputation: 292

You need to put them in the config file of the environment Like :

in config_dev.yml:
imports:
    - { resource: config.yml }
ip:     "127.0.0.1"

in config_env1.yml:
imports:
    - { resource: config.yml }
ip:     "192.58.56.46"

in config.yml:
ip: "%ip%"

Upvotes: 1

Related Questions