Answer the question
In order to leave comments, you need to log in
How to cross "symfony/dependency-injection" with environment variables?
I don't use a framework. Components only. The service container does not see the variable from the environment. I created a .env file - I wrote down the DSN variable (MESSENGER_TRANSPORT_DSN) there to use it in the configuration. Before creating a container, I load environment variables from a file
$dotenv = new Dotenv();
//$dotenv->usePutenv();
$dotenv->bootEnv('../.env');
arguments:
$dsn: '%env(MESSENGER_TRANSPORT_DSN)%'
Answer the question
In order to leave comments, you need to log in
https://github.com/symfony/symfony/blob/5.4/src/Sy...
/**
* @param bool $resolveEnvPlaceholders Whether %env()% parameters should be resolved using the current
* env vars or be replaced by uniquely identifiable placeholders.
* Set to "true" when you want to use the current ContainerBuilder
* directly, keep to "false" when the container is dumped instead.
*/
public function compile(bool $resolveEnvPlaceholders = false)
$container->compile(true);
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question