Description
Symfony version(s) affected: 4/5
Description
Anytime I try pass .env variables to bundle configs I get some sort of hashed values, f.e. for APP_LOCALE=en_US in the DI Extension class the value would be something like env_a47b1458111e54d0_APP_LOCALE_21afb7caede432771a62c6afa3f24e39
. Which makes some bundles incompatible with environment dependant apps.
How to reproduce
- Install fresh version of symfony plus add doctrine phpcr bundle (execute recipe)
$: symfony new 5
$: cd 5
5$: composer.phar require doctrine/phpcr-bundle
- Replace
.env
with:
APP_ENV=dev
APP_SECRET=a7ea38db584af1423a361cb69a246f42
DATABASE_URL="postgresql://db_user:db_password@127.0.0.1:5432/db_name?serverVersion=13&charset=utf8"
PHPCR_USER=admin
PHPCR_PASSWORD=admin
PHPCR_WORKSPACE=default
APP_LOCALE=en_US
APP_LOCALES_OBJ="{\"en_US\":{}}"
- Replace
config/packages/doctrine_phpcr.yaml
with:
doctrine_phpcr:
session:
backend:
type: jackrabbit
url: 'localhost'
workspace: '%env(PHPCR_WORKSPACE)%'
username: '%env(PHPCR_USER)%'
password: '%env(PHPCR_PASSWORD)%'
odm:
auto_mapping: true
auto_generate_proxy_classes: false
locales: '%env(json:APP_LOCALES_OBJ)%'
locale_fallback: hardcoded
default_locale: '%env(string:APP_LOCALE)%'
- Try access console:
5$: php bin/consle -vv
which will omit exception:
In DoctrinePHPCRExtension.php line 394:
[ErrorException]
Warning: Invalid argument supplied for foreach()
Exception trace:
at ./5/vendor/doctrine/phpcr-bundle/src/DependencyInjection/DoctrinePHPCRExtension.php:394
if to add dd($config['locales']);
before line 394 in DoctrinePHPCRExtension.php the output would be:
env_559c9450e41e23c7_json_APP_LOCALES_OBJ_1c159ebab1052f51822d2f70b32fa4e1
instead of array.
If using the same approach, but in parameters (add parameter locales: '%env(json:APP_LOCALES_OBJ)%'
in services.yaml) and access it via container somewhere in the service like $this->container->getParameter('locales');
it will have a valid array value.
Possible solution
Don't know one, maybe it is supposed to be like that? But it seems to be quite a big limitation.