symfony:如何为不同环境设置配置参数文件? [英] symfony: How to set configuration parameters files for different environments?

查看:30
本文介绍了symfony:如何为不同环境设置配置参数文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何为每个环境设置不同的配置参数文件?

How to setup a different configuration parameters file for each environment?

目前parameters.yml中的参数同时用于devprod环境,但我需要不同的参数才能部署我的应用正在生产中.

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:如何为不同环境设置配置参数文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆