发布于 2015-08-27 16:24:44 | 251 次阅读 | 评论: 0 | 来源: 网络整理
Configuration usually involves different application parts (such as infrastructure and security credentials) and different environments (development, production). That’s why Symfony recommends that you split the application configuration into three parts.
最佳实践
Don’t define a semantic dependency injection configuration for your bundles.
As explained in 如何在Bundle内部载入Service配置 article, Symfony bundles have two choices on how to handle configuration: normal service configuration through the services.yml
file and semantic configuration through a special *Extension
class.
Although semantic configuration is much more powerful and provides nice features such as configuration validation, the amount of work needed to define that configuration isn’t worth it for bundles that aren’t meant to be shared as third-party bundles.
When dealing with sensitive options, like database credentials, we also recommend that you store them outside the Symfony project and make them available through environment variables. Learn how to do it in the following article: 如何将Service Container的参数暴露到外部