douhe2305 2018-12-05 16:38
浏览 190
已采纳

Symfony 3.4使用parameters.yml中的变量覆盖env变量

I have the following setup which appeared to work for some time: environment variables like TEST=1 and defined defaults in parameters.yml, according to the config:

parameters:
    env(TEST): 2

When I go to console and output the container params, it's always the value from parameters.yaml:

bin/console debug:container --parameters | grep env
env(TEST) 2

I also tried doing exactly as it's said in the docs:

TEST: "%env(TEST)%"
env(TEST): 2

Now when I dump the parameters, I have both of them:

bin/console debug:container --parameters | grep env
TEST %env(TEST)%
env(TEST) 2

To be more precise: I use docker setup, and printenv inside a container gives me my TEST=1 shown.

Can someone explain me what happens/happened here? It's been working for some time, and then, probably after some major update, got broken.

I tried debugging it and got to a very strange place in Symfony sources: https://github.com/symfony/symfony/blob/3.4/src/Symfony/Component/DependencyInjection/ContainerBuilder.php#L1416

At that very line, there's a value "2" being passed, and it doesn't meet the conditions and gets returned.

  • 写回答

1条回答 默认 最新

  • douyin7829 2019-01-21 14:14
    关注

    Looks like everything works correctly - it's just the parameter debug output that confused me.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 在若依框架下实现人脸识别
  • ¥15 网络科学导论,网络控制
  • ¥100 安卓tv程序连接SQLSERVER2008问题
  • ¥15 利用Sentinel-2和Landsat8做一个水库的长时序NDVI的对比,为什么Snetinel-2计算的结果最小值特别小,而Lansat8就很平均
  • ¥15 metadata提取的PDF元数据,如何转换为一个Excel
  • ¥15 关于arduino编程toCharArray()函数的使用
  • ¥100 vc++混合CEF采用CLR方式编译报错
  • ¥15 coze 的插件输入飞书多维表格 app_token 后一直显示错误,如何解决?
  • ¥15 vite+vue3+plyr播放本地public文件夹下视频无法加载
  • ¥15 c#逐行读取txt文本,但是每一行里面数据之间空格数量不同