2

I have the same problem as here.

What I already did:

  1. Generated the keys with php bin/console secrets:set DATABASE_PASSWORD (both for dev and prod)
  2. Variable can be seen with php bin/console secrets:list
  3. I am trying to reference it inside the doctrine.yaml file with '%env(DATABASE_PASSWORD)%'
  4. And I get an exception (Environment variable not found: "DATABASE_PASSWORD").

I have a sodium extension enabled in main ini.file. Any idea what's wrong and what is missing?

Loghorrean
  • 41
  • 1
  • 4
  • 1
    You refer to another question that refers to another question. Both your and prev question have no problem reproduction in body, only reference to the previous question. You might have more luck with help here if you describe the problem within the question and only link the old question as mention that it was already asked. – Ruli Jan 17 '21 at 07:59
  • Still having trouble with this? Might try a bin/console cache:clear. I never knew the about this secret subsystem. Followed the docs on a fresh 5.2 install and it all worked as described. Maybe you are trying to run it in production and [did not follow these steps](https://symfony.com/doc/current/configuration/secrets.html#deploy-secrets-to-production)? – Cerad Jan 17 '21 at 15:14
  • Though I wasn't running production, clearing cache seems to be working in dev, which is what I wanted. Your answer helped, but I have another question: is it possible to reference one env variable inside another, like database_password inside database-url using %env()%? – Loghorrean Jan 18 '21 at 00:37
  • In general you should avoid asking additional questions in the comment section. But the answer is no, you cannot embed stuff like that. However, a look at 'bin/console config:dump-reference doctrine' reveals you can specify your database connection parameters individually. In other words, password: %env-whatever% will do the trick. But make sure you have a good reason to go down this route and use secrets. Simply setting env variables in production is more than secure enough for most applications. – Cerad Jan 18 '21 at 02:42

0 Answers0