zegifus
zegifus

Reputation: 11

How to get environment in config.yml?

In app/config/config.yml I have for example:

samplebundle:
    link: "/admin"

How can I add for this current environment?

Something like that...

samplebundle:
    link: "{env}/admin"

If I am in dev env (app_dev.php) then I want the link to be with app_dev.php.

Upvotes: 0

Views: 104

Answers (2)

DrKey
DrKey

Reputation: 3495

You will find environment parameter on kernel.environment by default

samplebundle:
    link: "%kernel.environment%/admin"

Upvotes: 2

Alessandro Minoccheri
Alessandro Minoccheri

Reputation: 35973

I advise you to put your configuration inside every config environment like this for example:

config_dev.yml

samplebundle:
    link: "dev/admin"

config_prod.yml

samplebundle:
    link: "prod/admin"

config_test.yml

samplebundle:
    link: "test/admin"

Another solution solution is to put in every parameters configuration a value like this:

parameters_dev.yml

parameters:
    env: 'dev'

And into your config.yml call this:

samplebundle:
        link: "%env%/admin"

Upvotes: 0

Related Questions