function Container::getEnv
Fetches a variable from the environment.
Throws
EnvNotFoundException When the environment variable is not found and has no default value
2 calls to Container::getEnv()
- ContainerBuilder::getEnv in vendor/
symfony/ dependency-injection/ ContainerBuilder.php - Fetches a variable from the environment.
- ContainerBuilder::getEnv in vendor/
symfony/ dependency-injection/ ContainerBuilder.php - Fetches a variable from the environment.
1 method overrides Container::getEnv()
- ContainerBuilder::getEnv in vendor/
symfony/ dependency-injection/ ContainerBuilder.php - Fetches a variable from the environment.
File
-
vendor/
symfony/ dependency-injection/ Container.php, line 341
Class
- Container
- Container is a dependency injection container.
Namespace
Symfony\Component\DependencyInjectionCode
protected function getEnv(string $name) : mixed {
if (isset($this->resolving[$envName = "env({$name})"])) {
throw new ParameterCircularReferenceException(array_keys($this->resolving));
}
if (isset($this->envCache[$name]) || \array_key_exists($name, $this->envCache)) {
return $this->envCache[$name];
}
if (!$this->has($id = 'container.env_var_processors_locator')) {
$this->set($id, new ServiceLocator([]));
}
$this->getEnv ??= $this->getEnv(...);
$processors = $this->get($id);
if (false !== ($i = strpos($name, ':'))) {
$prefix = substr($name, 0, $i);
$localName = substr($name, 1 + $i);
}
else {
$prefix = 'string';
$localName = $name;
}
$processor = $processors->has($prefix) ? $processors->get($prefix) : new EnvVarProcessor($this);
if (false === $i) {
$prefix = '';
}
$this->resolving[$envName] = true;
try {
return $this->envCache[$name] = $processor->getEnv($prefix, $localName, $this->getEnv);
} finally {
unset($this->resolving[$envName]);
}
}