-
-
Notifications
You must be signed in to change notification settings - Fork 9.7k
Description
Q | A |
---|---|
Bug report? | no |
Feature request? | yes (kind of) |
BC Break report? | no |
RFC? | yes |
Symfony version | 3.2 |
Recently, I stumbled upon an issue with environment variables that I had troubles to understand. Here it is:
I have two environment variables, defined in my parameters.yml
with a default value of empty:
parameters:
env(MAILJET_PUBLIC_KEY): ''
env(MAILJET_PRIVATE_KEY): ''
I use these variables only in a private service:
<service id="app.mailjet.transport" class="AppBundle\Mailjet\MailjetApiTransport" public="false">
<argument type="service" id="csa_guzzle.client.mailjet_api"/>
<argument>%env(MAILJET_PUBLIC_KEY)%</argument>
<argument>%env(MAILJET_PRIVATE_KEY)%</argument>
</service>
This private service is not used by any other service for the moment.
As the service is private and not used by any other service, the RemoveUnusedDefinitionsPass
removes it from the container. However, when the container dumper dumps the container, it checks if the environment variable was dumped. As the service is now gone, an expection is thrown (EnvParameterException, Incompatible use of dynamic environment variables "MAILJET_PUBLIC_KEY", "MAILJET_PRIVATE_KEY" found in parameters.
).
I suggest to add a tracking of environment variables in the RemoveUnusedDefinitionsPass
in order to avoid this issue as it is difficult to understand for newcomers and may lead to troubles.