<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.4.0-DEV</td>
</tr>
</tbody>
</table>
<p dir="auto">When trying to use an env() placeholder on a config option that is being validated, it takes the placeholder literally and it fails the validation.</p>
<p dir="auto">Here's a fresh new project replicating the error:<br>
<a href="https://github.com/symfony/symfony-standard/compare/master...felds:config-vs-env?expand=1">https://github.com/symfony/symfony-standard/compare/master...felds:config-vs-env?expand=1</a></p>
<p dir="auto">Relevant changes:</p>
<div class="highlight highlight-source-yaml notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="# app/config/config.yml
parameters:
    env(SMTP_HOST): smtp.example.com
    env(SMTP_ENCRYPTION): tls
swiftmailer:
    host: &quot;%env(SMTP_HOST)%&quot; # &lt;-- this works…
    encryption: &quot;%env(SMTP_ENCRYPTION)%&quot; # &lt;-- but this breaks"><pre class="notranslate"><span class="pl-c"><span class="pl-c">#</span> app/config/config.yml</span>
<span class="pl-ent">parameters</span>:
    <span class="pl-ent">env(SMTP_HOST)</span>: <span class="pl-s">smtp.example.com</span>
    <span class="pl-ent">env(SMTP_ENCRYPTION)</span>: <span class="pl-s">tls</span>
<span class="pl-ent">swiftmailer</span>:
    <span class="pl-ent">host</span>: <span class="pl-s"><span class="pl-pds">"</span>%env(SMTP_HOST)%<span class="pl-pds">"</span></span> <span class="pl-c"><span class="pl-c">#</span> &lt;-- this works…</span>
    <span class="pl-ent">encryption</span>: <span class="pl-s"><span class="pl-pds">"</span>%env(SMTP_ENCRYPTION)%<span class="pl-pds">"</span></span> <span class="pl-c"><span class="pl-c">#</span> &lt;-- but this breaks</span></pre></div>
<div class="highlight highlight-source-yaml notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="swiftmailer:
    transport:  '%env(MAILER_TRANSPORT)%'
    host:       '%env(MAILER_HOST)%'
    port:       '%env(MAILER_PORT)%'
    encryption: '%env(MAILER_ENCRYPTION)%'
    username:   '%env(MAILER_USER)%'
    password:   '%env(MAILER_PASS)%'"><pre class="notranslate"><span class="pl-ent">swiftmailer</span>:
    <span class="pl-ent">transport</span>:  <span class="pl-s"><span class="pl-pds">'</span>%env(MAILER_TRANSPORT)%<span class="pl-pds">'</span></span>
    <span class="pl-ent">host</span>:       <span class="pl-s"><span class="pl-pds">'</span>%env(MAILER_HOST)%<span class="pl-pds">'</span></span>
    <span class="pl-ent">port</span>:       <span class="pl-s"><span class="pl-pds">'</span>%env(MAILER_PORT)%<span class="pl-pds">'</span></span>
    <span class="pl-ent">encryption</span>: <span class="pl-s"><span class="pl-pds">'</span>%env(MAILER_ENCRYPTION)%<span class="pl-pds">'</span></span>
    <span class="pl-ent">username</span>:   <span class="pl-s"><span class="pl-pds">'</span>%env(MAILER_USER)%<span class="pl-pds">'</span></span>
    <span class="pl-ent">password</span>:   <span class="pl-s"><span class="pl-pds">'</span>%env(MAILER_PASS)%<span class="pl-pds">'</span></span></pre></div>
<p dir="auto">This config throws a <code class="notranslate">The "%env(MAILER_ENCRYPTION)%" encryption is not supported</code> exception.</p>
<p dir="auto">This happens because of the <code class="notranslate">-&gt;ifNotInArray(array('tls', 'ssl', null))</code> check. <code class="notranslate">ContainerBuilder::resolveEnvPlaceholders</code> happens later.</p>