针对不同环境条件化数据库设置的 Drupal 7 方式是什么?
我一直习惯于对 $_SEVER['HTTP_HOST'] 进行测试,然后选择一组不同的设置,如下所示:
switch ($_SERVER['HTTP_HOST']) {
case 'prod.myserver.com':
$database = "settings for prod";
break;
case 'stage.myserver.com':
$database = "settings for staging";
break;
case 'dev.myserver.com':
$database = "settings for dev";
break;
}
settings.php 中的新设置使其看起来可能有更复杂的设置现在就这样。有没有?
I've been in the habit of doing a test of $_SEVER['HTTP_HOST'] and then choosing a different set of settings, like this:
switch ($_SERVER['HTTP_HOST']) {
case 'prod.myserver.com':
$database = "settings for prod";
break;
case 'stage.myserver.com':
$database = "settings for staging";
break;
case 'dev.myserver.com':
$database = "settings for dev";
break;
}
The new set-up in settings.php makes it look like there might be a more sophisticated way now. Is there?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
site.php 听起来像您正在寻找的内容
,然后您可以创建
参见 http://api.drupal.org/api/drupal/sites--example.sites.php/7
sites.php sounds like what you are looking for
then you can create
See http://api.drupal.org/api/drupal/sites--example.sites.php/7
我只使用 Acquia 推荐的格式: https://docs.acquia .com/cloud-platform/develop/env-variable/#examples
I just use the format Acquia recommends: https://docs.acquia.com/cloud-platform/develop/env-variable/#examples