设置每个环境的螺栓配置

Setting Bolt Configuration Per Environment

Bolt documentation提到为每个环境设置配置文件,但没有解释如何实现。

When you have multiple environments for the same site, like development, staging, or production, you’ll want parts of the config to be the same, and some different per environment. You’ll probably have different database info and debug settings. This can be accomplished by splitting the config.yml file. Put all settings you share over all environments in the default config.yml, you can commit this in your version control system if wanted. Every setting which is different per environment, or which you do not want in version control (like database info), you put in config_local.yml. First config.yml is loaded and then config_local.yml, so that config_local.yml can override any setting in config.yml.

当然,我创建一个额外的配置文件没有问题,但是我如何告诉 Bolt 它 运行 在哪个环境中以及它应该加载哪个文件?

原来博尔特完全不知道它的环境。它 总是 加载 config.yml 后跟 config_local.yml,与域名无关。

来自 Config.php,从第 226 行开始:

protected function parseGeneral()
{
    // Read the config and merge it. (note: We use temp variables to prevent
    // "Only variables should be passed by reference")
    $tempconfig = $this->parseConfigYaml('config.yml');
    $tempconfiglocal = $this->parseConfigYaml('config_local.yml');
    $general = Arr::mergeRecursiveDistinct($tempconfig, $tempconfiglocal);

我的问题的解决方案是永远不允许 config_local.yml 部署。

config_local.yml 文件旨在供开发使用,以便您可以覆盖可能在生产使用中提交给 VCS 的配置设置。