Symfony options not found in environment variable

I am on Symfony 2.8.12 This is my file parameters.yml:

parameters:
    database_host: localhost
    database_port: 3306
    database_name: test
    database_user: root
    secret: TODO

I have an environment variable SYMFONY__DATABASE_PASSWORDequal to root If I started app/console debug:container --parameter="database_password", I have

 ------------------- -------
  Parameter           Value
 ------------------- -------
  database_password   root
 ------------------- -------

But when I go to localhost / app_dev.php, I have

ParameterNotFoundException in ParameterBag.php line 84:
You have requested a non-existent parameter "database_password". Did you mean this: "database_port"?

The same after clearing the cache

Doc: http://symfony.com/doc/current/configuration/external_parameters.html

+4
source share
2 answers

When used, phpinfo()and the php -ivariable appears in $_ENV[] (that is, the environment variables are not combined with the servers) try adding this line toapp_dev.php

$_SERVER = array_merge($_SERVER, $_ENV);
0
source

You must “export” the shell variable. A type:

export SYMFONY__DATABASE__PASSWORD = 'root'

-1

Source: https://habr.com/ru/post/1660076/


All Articles