Ali Mhanna
Ali Mhanna

Reputation: 209

How to use environment variables to set some parameters instead of parameters.yml?

I am trying to set my database name and password as environment variables in symfony 3.4 app

I already did change the values inside the config file to:

    dbname: '%env(DB_NAME)%'
    user: '%env(DB_USER)%'
    password: '%env(DB_PASSWORD)%'

this is the error i am getting it seems its not checking env() at all

You have requested a non-existent parameter "env(DB_NAME)".

Am I missing something here? I tried also the dotenv component but I could not install it with symfony 3.4.

Upvotes: 0

Views: 361

Answers (1)

Ali Mhanna
Ali Mhanna

Reputation: 209

I found what causing the error after installing "UnifikDatabaseConfigBundle" it adds to the AppKernel a function:

protected function getContainerBuilder()
{
    return new ContainerBuilder(new ParameterBag($this->getKernelParameters()));
}

and this function causing this error thanks every one for your help

Upvotes: 1

Related Questions