Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Parse environment variable into array #40906

Closed
@Nyholm

Description

@Nyholm

Symfony version(s) affected: 5.2.6

Description
I cannot parse an environment variable into an array.

How to reproduce

# env
TRUSTED_HOSTS="[\"10.0.0.1\", \"10.0.0.2\"]"
# config/packages/framework.yaml
framework:
    trusted_hosts: '%env(json:TRUSTED_HOSTS)%'

I get:

Invalid type for path “framework.trusted_hosts.0”. Expected one of “bool”, “int”, “float”, “string”, but got “array”.

See reproducer repo: https://github.com/Nyholm/sf-issue-40906

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