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.

图片转代码服务由CSDN问答提供 功能建议

我有以下设置似乎工作了一段时间:环境变量如TEST = 1和参数中定义的默认值 .yml,根据配置:

 参数:
 env(TEST):2 
   
 
 

我去控制台并输出容器参数,它总是来自parameters.yaml的值:

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

我也尝试过完全按照文档中的说法进行操作:

  TEST:“%env(TEST)%”
env(TEST):2 
   
 
 

现在当我转储参数时,我同时拥有它们:

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

更确切地说:我使用docker setup,并且容器内的printenv给了我 我的TEST = 1显示。

有人可以解释一下这里发生了什么/发生了什么? 它已经工作了一段时间,然后,可能在一些重大更新后,它被打破了。

我尝试调试它并进入Symfony来源的一个非常奇怪的地方: https://github.com/symfony/symfony/blob /3.4/src/Symfony/Component/DependencyInjection/ContainerBuilder.php#L1416

在那一行,传递了一个值“2”,它没有 符合条件并返回。

  • 写回答
  • 好问题 提建议
  • 追加酬金
  • 关注问题
  • 邀请回答

1条回答 默认 最新

相关推荐 更多相似问题