配置参数

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.

避免在Symfony项目里泄露敏感配置

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的参数暴露到外部