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

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.

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

报告相同问题?

悬赏问题

  • ¥20 关于php录入完成后,批量更新数据库
  • ¥15 请教往复密封润滑问题
  • ¥15 cocos creator发布ios包
  • ¥15 comsol压电材料数据
  • ¥35 用python实现除法算法中goldschmidt算法
  • ¥15 汇编代码转换成C代码
  • ¥15 除法算法中的归一化具体是怎么变的?
  • ¥20 集成电路的逻辑电路和晶体管简化图
  • ¥15 下载windows builder后的问题
  • ¥15 端口连接数为什么会有限制