繁体   English   中英

如何在参数文件中包含数组?

[英]How to have an array in a parameter file?

我正在使用Symfony2.1,并且需要将一个数组保存在config / parameter文件中,因为我经常会修改该数组的内容(大概每6个月一次)(它包含电子邮件地址)。

我知道我可以使用以下命令将字符串保存在parameters.yml中:

在app / config / parameters.yml中

parameters
    address: 'example@domain.com'

并在控制器中使用$ this-> container-> getParameter('address')检索此参数,但是我有很多接收者,并且我希望有类似以下内容:

    parameters
        address: array('example@domain.com', 'example2@domain.com', 'example3@domain.com)
#the number of addresses is actually not defined

数组的Yaml语法为:

address: 
    - example@domain.com
    - example2@domain.com
    - example3@domain

要么

address: ["example1@domain.com", "example2@domain.com"]

但我不知道symfony是否支持这一点。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM