Reputation: 839
I work on a symfony project and I want to do something like this in my app/config/parameters.yml
dev.google.api.key: foo
google: %%kernel.environment%.google%
It not works.
I explain : I want to have the variable google to have values depending my environment (env or prod).
So I defined two variable :
dev.google.api.key: foo
prod.google.api.key: bar
I want to have my variable google to be filled with content depending on the environment. The environment is in the variable
%kernel.environment%
So if I do :
google: %kernel.environment%.google
Google is equal to "dev.google" but I want to this string to be evaluated like this %dev.google%. But %%kernel.environment%.google% not works.
An idea ? Thanks
Upvotes: 0
Views: 409
Reputation: 5782
You can try something like this:
in your config_dev.yml:
parameters:
google.api.key: foo
in your config_prod.yml:
parameters:
google.api.key: bar
in your config.yml:
google: %google.api.key%
Or
Create paramater_dev.yml with
parameters:
google.api.key: foo
Create paramater_prod.yml with
parameters:
google.api.key: bar
in your config_dev.yml:
imports:
- { resource: paramater_dev.yml }
- { resource: config.yml }
in your config_prod.yml:
imports:
- { resource: paramater_prod.yml }
- { resource: config.yml }
in your config.yml:
google: %google.api.key%
Upvotes: 3