<table role="table">
<thead>
<tr>
<th>Q</th>
<th>A</th>
</tr>
</thead>
<tbody>
<tr>
<td>Bug report?</td>
<td>yes</td>
</tr>
<tr>
<td>Feature request?</td>
<td>no</td>
</tr>
<tr>
<td>BC Break report?</td>
<td>no</td>
</tr>
<tr>
<td>RFC?</td>
<td>no</td>
</tr>
<tr>
<td>Symfony version</td>
<td>dev-master</td>
</tr>
</tbody>
</table>
<p dir="auto">I have reproduced this in a small example in <a href="https://github.com/zippy1981/symphony-dependency-env">this git repository</a>.</p>
<p dir="auto">If I load my dependency injection configuration from a config file that looks like this the environment variables aren't parsed.</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="parameters:
    log.file: '%env(APP_LOG)%'
    log.level: '%env(LOGGING_LEVEL)%'
services:
    stream_handler:
	class:     \Monolog\Handler\StreamHandler
	arguments:
	 - '%log.file%'
	 - '%log.level%'
    log:
	class:     \Monolog\Logger
	arguments: [ 'default',  ['@stream_handler']  ]"><pre class="notranslate"><code class="notranslate">parameters:
    log.file: '%env(APP_LOG)%'
    log.level: '%env(LOGGING_LEVEL)%'
services:
    stream_handler:
	class:     \Monolog\Handler\StreamHandler
	arguments:
	 - '%log.file%'
	 - '%log.level%'
    log:
	class:     \Monolog\Logger
	arguments: [ 'default',  ['@stream_handler']  ]
</code></pre></div>
<p dir="auto">The error I get looks like:</p>
<blockquote>
<p dir="auto">Fatal error: Uncaught UnexpectedValueException: The stream or file "env_PATH_a61e1e48db268605210ee2286597d6fb" could not be opened: failed to open stream: Permission denied in /var/www/vendor/monolog/monolog/src/Monolog/Handler/StreamHandler.php:107 Stack trace: #0 /var/www/vendor/monolog/monolog/src/Monolog/Handler/AbstractProcessingHandler.php(37): Monolog\Handler\StreamHandler-&gt;write(Array) <a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="298110" data-permission-text="Title is private" data-url="https://github.com/symfony/symfony/issues/1" data-hovercard-type="pull_request" data-hovercard-url="/symfony/symfony/pull/1/hovercard" href="https://github.com/symfony/symfony/pull/1">#1</a> /var/www/vendor/monolog/monolog/src/Monolog/Logger.php(337): Monolog\Handler\AbstractProcessingHandler-&gt;handle(Array) <a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="298116" data-permission-text="Title is private" data-url="https://github.com/symfony/symfony/issues/2" data-hovercard-type="pull_request" data-hovercard-url="/symfony/symfony/pull/2/hovercard" href="https://github.com/symfony/symfony/pull/2">#2</a> /var/www/vendor/monolog/monolog/src/Monolog/Logger.php(532): Monolog\Logger-&gt;addRecord(100, 'Initialized dep...', Array) <a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="299923" data-permission-text="Title is private" data-url="https://github.com/symfony/symfony/issues/3" data-hovercard-type="pull_request" data-hovercard-url="/symfony/symfony/pull/3/hovercard" href="https://github.com/symfony/symfony/pull/3">#3</a> /var/www/html/index.php(17): Monolog\Logger-&gt;debug('Initialized dep...') <a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="301814" data-permission-text="Title is private" data-url="https://github.com/symfony/symfony/issues/4" data-hovercard-type="pull_request" data-hovercard-url="/symfony/symfony/pull/4/hovercard" href="https://github.com/symfony/symfony/pull/4">#4</a> {main} thrown in /var/www/vendor/monolog/monolog/src/Monolog/Handler/StreamHandler.php on line 107</p>
</blockquote>
<p dir="auto">I've <a href="http://stackoverflow.com/questions/43050669/symfony-yaml-backed-symfony-config-not-parsing-environment-variables" rel="nofollow">asked on stack overflow to no response</a>.</p>
<p dir="auto">It seems the root of the problem is <a href="https://github.com/symfony/symfony/blob/df7f83ca6d0d941f591ccb846286e06dfa834ced/src/Symfony/Component/DependencyInjection/ContainerBuilder.php#L1037">ContainerBuilder::resolveEnvPlaceholders()</a> is never called.</p>
<table role="table">
<thead>
<tr>
<th>Q</th>
<th>A</th>
</tr>
</thead>
<tbody>
<tr>
<td>Bug report?</td>
<td>yes</td>
</tr>
<tr>
<td>Feature request?</td>
<td>no</td>
</tr>
<tr>
<td>BC Break report?</td>
<td>no</td>
</tr>
<tr>
<td>RFC?</td>
<td>no</td>
</tr>
<tr>
<td>Symfony version</td>
<td>3.2.2</td>
</tr>
</tbody>
</table>
<p dir="auto">Hi,</p>
<p dir="auto">I'm trying to use the new <code class="notranslate">env()</code> placeholder introduced with <a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="172265483" data-permission-text="Title is private" data-url="https://github.com/symfony/symfony/issues/19681" data-hovercard-type="pull_request" data-hovercard-url="/symfony/symfony/pull/19681/hovercard" href="https://github.com/symfony/symfony/pull/19681">#19681</a>, but I can't get it to work. I installed <code class="notranslate">symfony/dependency-injection|config|yaml</code>, and I followed <a href="https://symfony.com/doc/current/components/dependency_injection.html#setting-up-the-container-with-configuration-files" rel="nofollow">Setting up the Container with Configuration Files</a>.</p>
<p dir="auto">This is my script—mostly copy/pasted from the documentation:</p>
<div class="highlight highlight-text-html-php notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="&lt;?php

require __DIR__ . '/vendor/autoload.php';

use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\Config\FileLocator;
use Symfony\Component\DependencyInjection\Loader\YamlFileLoader;

$container = new ContainerBuilder();
$loader = new YamlFileLoader($container, new FileLocator(__DIR__));
$loader-&gt;load('services.yml');

var_dump(getenv('NAME'));
var_dump($container-&gt;getParameter('test'));"><pre class="notranslate"><span class="pl-ent">&lt;?php</span>

<span class="pl-k">require</span> __DIR__ . <span class="pl-s">'/vendor/autoload.php'</span>;

<span class="pl-k">use</span> <span class="pl-v">Symfony</span>\<span class="pl-v">Component</span>\<span class="pl-v">DependencyInjection</span>\<span class="pl-v">ContainerBuilder</span>;
<span class="pl-k">use</span> <span class="pl-v">Symfony</span>\<span class="pl-v">Component</span>\<span class="pl-v">Config</span>\<span class="pl-v">FileLocator</span>;
<span class="pl-k">use</span> <span class="pl-v">Symfony</span>\<span class="pl-v">Component</span>\<span class="pl-v">DependencyInjection</span>\<span class="pl-v">Loader</span>\<span class="pl-v">YamlFileLoader</span>;

<span class="pl-s1"><span class="pl-c1">$</span>container</span> = <span class="pl-k">new</span> <span class="pl-v">ContainerBuilder</span>();
<span class="pl-s1"><span class="pl-c1">$</span>loader</span> = <span class="pl-k">new</span> <span class="pl-v">YamlFileLoader</span>(<span class="pl-s1"><span class="pl-c1">$</span>container</span>, <span class="pl-k">new</span> <span class="pl-v">FileLocator</span>(__DIR__));
<span class="pl-s1"><span class="pl-c1">$</span>loader</span>-&gt;<span class="pl-en">load</span>(<span class="pl-s">'services.yml'</span>);

var_dump(getenv(<span class="pl-s">'NAME'</span>));
var_dump(<span class="pl-s1"><span class="pl-c1">$</span>container</span>-&gt;<span class="pl-en">getParameter</span>(<span class="pl-s">'test'</span>));</pre></div>
<p dir="auto">This is my <code class="notranslate">services.yml</code> file:</p>
<div class="highlight highlight-source-yaml notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="parameters:
  test: '%env(NAME)%'"><pre class="notranslate"><span class="pl-ent">parameters</span>:
  <span class="pl-ent">test</span>: <span class="pl-s"><span class="pl-pds">'</span>%env(NAME)%<span class="pl-pds">'</span></span></pre></div>
<p dir="auto">And this is the output of the command <code class="notranslate">NAME=madonna php test.php</code>:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="/Volumes/GIT/olvlvl/test-di-env/test.php:13:
string(7) &quot;madonna&quot;
/Volumes/GIT/olvlvl/test-di-env/test.php:14:
string(11) &quot;%env(NAME)%&quot;"><pre lang="raw" class="notranslate"><code class="notranslate">/Volumes/GIT/olvlvl/test-di-env/test.php:13:
string(7) "madonna"
/Volumes/GIT/olvlvl/test-di-env/test.php:14:
string(11) "%env(NAME)%"
</code></pre></div>
<p dir="auto">I also read <a href="http://symfony.com/doc/current/configuration/external_parameters.html" rel="nofollow">How to Set external Parameters in the Service Container</a> but it doesn't give more information, so I'm not sure what's wrong.</p>
<p dir="auto">Here is the package list:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="symfony/config               v3.2.2 Symfony Config Component
symfony/dependency-injection v3.2.2 Symfony DependencyInjection Component
symfony/filesystem           v3.2.2 Symfony Filesystem Component
symfony/yaml                 v3.2.2 Symfony Yaml Component"><pre class="notranslate"><code class="notranslate">symfony/config               v3.2.2 Symfony Config Component
symfony/dependency-injection v3.2.2 Symfony DependencyInjection Component
symfony/filesystem           v3.2.2 Symfony Filesystem Component
symfony/yaml                 v3.2.2 Symfony Yaml Component
</code></pre></div>
<p dir="auto">Can you help?</p>