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.

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

报告相同问题?

悬赏问题

  • ¥15 求daily translation(DT)偏差订正方法的代码
  • ¥15 js调用html页面需要隐藏某个按钮
  • ¥15 ads仿真结果在圆图上是怎么读数的
  • ¥20 Cotex M3的调试和程序执行方式是什么样的?
  • ¥20 java项目连接sqlserver时报ssl相关错误
  • ¥15 一道python难题3
  • ¥15 牛顿斯科特系数表表示
  • ¥15 arduino 步进电机
  • ¥20 程序进入HardFault_Handler
  • ¥15 关于#python#的问题:自动化测试