Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

[DI] ENV parameters at runtime with PHP 7 strict types not working properly #20434

Copy link
Copy link
Closed
@sandrokeil

Description

@sandrokeil
Issue body actions

I'm just playing around with the Symfony 3.2 Beta and Runtime Environment Variables.

There are two problems:

  1. It's not data type aware
  2. It's not working if environment parameter is a service name
  3. 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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.