问题描述
如何为每个环境设置不同的配置参数文件?
How to setup a different configuration parameters file for each environment?
目前parameters.yml
中的参数同时用于dev
和prod
环境,但我需要不同的参数才能部署我的应用正在生产中.
At the moment parameters in parameters.yml
are used in both dev
and prod
environment, but I need different parameters in order to deploy my app in prod.
推荐答案
您可以将 dev
环境中使用的所有参数放在 app\config\parameters_dev.yml
中> 文件(你需要创建它),然后将它导入你的app\config\config_dev.yml
:
You can put all the parameters used in your dev
environment in a app\config\parameters_dev.yml
file (you need to create it) and then import it in your app\config\config_dev.yml
:
imports:
- { resource: config.yml }
- { resource: parameters_dev.yml }
因此,当您在本地工作时,生产中使用的任何参数都将被具有正确参数的新文件覆盖.
So when you work in local any parameter used in production will be overwritten by the new file with the right parameters.
记得清除缓存!
这篇关于symfony:如何为不同环境设置配置参数文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!