【发布时间】:2012-12-01 16:33:29
【问题描述】:
我正在尝试在app/config/parameters.ini 中设置一个空值,并在app/config/config.yml 中为swiftmailer.encryption 配置参数使用它。我需要在 parameters.ini 中进行设置,因为我有不同的环境,每个环境使用不同的邮件配置。
Symfony documentation 表示此配置参数应为字符串值,并且“有效值为 tls、ssl 或 null”。
我的第一个猜测是将mailer_encryption="null" 添加到parameters.ini 并将encryption: %mailer_encryption% 添加到config.yml。但这会导致错误:
“InvalidConfigurationException:路径“swiftmailer.encryption”的配置无效:不支持“null”加密”。
如果我在parameters.ini 中使用mailer_encryption=null 或mailer_encryption=,我会得到另一个错误:
“InvalidConfigurationException:路径“swiftmailer.encryption”的配置无效:不支持“”加密”。
如果我通过将 config.yml 更改为 encryption: 来停止引用参数,它会起作用,但这并不能解决我的目标。
我正在使用 Symfony 2.0.15,其中包含 Swiftmailer。 This is the 2.0 branch.
我怎样才能让它工作?
【问题讨论】:
-
您可以尝试在您的 ini 文件中像这样使用
~:mailer_encryption = ~。 -
@Sgoettschkes 这会抛出“ErrorException: Warning: syntax error, unexpected END_OF_LINE in /path/to/parameters.ini”
-
你能不能为每个环境创建不同的 yml 文件,比如stackoverflow.com/questions/10014327/…
-
@Squazic 出于安全考虑,我想将所有这些内容保存在 parameters.ini 中。 parameters.ini 文件未提交到 repo。
-
AFAIK,可以使用yml格式的参数文件。所以尝试创建 parameters.yml 并将其导入到您的 config.yml
标签: symfony configuration swiftmailer