Description
I'm just playing around with the Symfony 3.2 Beta and Runtime Environment Variables.
There are two problems:
- It's not data type aware
- It's not working if environment parameter is a service name
- No
null
value support
1. It's not data type aware
All environment variables are strings e.g. if you use nginx + php-fpm. So we need a type cast on reading the environment variable. For example %env('MY_INTEGER', 'integer')%
or %env('MY_BOOLEAN', 'bool')%
etc. Otherwise it makes no sense, because you get errors like Invalid type for path "swiftmailer.mailers.default.disable_delivery". Expected boolean, but got string
.
How can we solve this?
2. It's not working if environment parameter is a service name
If I put the mailer_transport
parameter to an environment variable I get the error You have requested a non-existent service "%env(MAILER_TRANSPORT)%"
. This env variable has the value smtp
. I guess @fabpot mentioned this here.
Would be great if we can resolve this too. Any ideas?
3. No null
value support
It should be possible to allow default null
values or to allow not defined environment variables which have then as default value null
. The mailer_transport
parameter can be null.
With $container->setParameter('env(MY_DEFAULT_NULL)', null);
I get the error The default value of an env() parameter must be scalar, but "NULL" given
. And if this environment variable is not defined, I get the error Environment variable not found: "MY_DEFAULT_NULL"
.
/cc @nicolas-grekas