About IT and Sports

My Web development experiences and sports encounters


Handling settings.php in Drupal

When working with Drupal there is a moment where you have to think about the way you want to manage settings.php. This file contains important configuration settings like the database credentials. It is most often also used to add custom configuration settings. Drupal comes with a default version of this file and during installation Drupal will write the database settings to this file.

The problem
Many projects run in a DTAP (Development, Testing, Acceptance and Production) development process, using a SCM tool like git or svn in a multi developer and multi location environment. The following problems/requirement should have your attention:
1. Each DTAP environment have their own specific settings as does every developer. For instance the database settings. Changes to settings.php will probably lead to SCM conflicts.
2. From a security point of view you don’t want database passwords in version control. Especially when you are using an online service like github.com.
3. You want to be able to make environment specific settings (develop, test, acceptance, production). For instance when you have a Varnish instance which only runs on acceptance and production.
4. General configuration settings for all environments should be possible
5. You want to prevent working with local changes or unversioned files on any environments

The solution
To handle the requirement above, we have worked out way to achieve this:
- Database settings are taken out of settings.php and moved to a separate file env.settings.inc. This file is included from settings.php
- The file env.settings.inc is not added to version control. In git you can use .gitignore to keep it out of version control.
- In env.settings.inc a variable is included to define the environment:
$environment = “develop”; // Possible values: develop, acceptance, production

- Per environment a settings file is created: develop.settings.inc, etc. These files are included in settings.php and added to version control.
- General configuration settings which are needed for all environments are added to settings.php. Settings.php is also added to version control.

In settings.php we add the following:

if (file_exists (‘./’ .conf_path(). ‘/env.settings.inc’)) {
include_once(‘./’. conf_path(). ‘/env.settings.inc’);

if (file_exists (‘./’. conf_path(). ‘/’. $environment . ‘.settings.inc’)) {
include_once(‘./’. conf_path(). ‘/’. $environment . ‘.settings.inc’);

This solution meets all the requirements. It’s clean and and well-ordered. And most importantly it prevents a lot of irritations, because you don’t have conflicts on settings.php anymore. If you found any flaws in this configuration or if you have another strategy on settings.php, please share them.

This article was originaly posted on the Colours blog.

Tags: , ,

10.946 Responses to “Handling settings.php in Drupal”

  1. juli 22nd, 2021 at 10:03

    cheap jordans from china says:

    The rookie magic even affected the referee. The course notes said he enjoyed the fight only the veteran could enjoy. A lot of people said he could so easily dispossess defense personnel, since he had changed. But according to slow motion, the real reason was that 1st step was too fast, and for you to violate any rules.
    cheap jordans from china [url=https://www.airjordantrade.com]cheap jordans from china[/url]

  2. juli 22nd, 2021 at 23:51

    Ralphhic says:

    Vietnam city capital of China [url=https://www.datanumen.com/pdf-repair/] China 6 [/url]

  3. juli 23rd, 2021 at 07:07

    Cutterrmz says:

    reproduced by hand, in contrast

  4. juli 23rd, 2021 at 15:55

    Businessyds says:

    Duke de Montosier

  5. juli 25th, 2021 at 09:57

    Drywallqwu says:

    Since the era of Charlemagne

  6. juli 26th, 2021 at 05:49

    Louis Vuitton Handbags says:

    2 Nigo logo design elements blend in

  7. juli 26th, 2021 at 10:14

    HoraceDaync says:

    Глазеть [url=https://seksa.top/]цыганская порнуха[/url] онлайн в https://seksa.top/categories/%D0%9C%D0%BE%D0%BB%D0%BE%D0%B4%D1%8B%D0%B5/ HD. Порно видео. Seksa.top – красивая порнуха [url=https://seksa.top/categories/%D0%90%D0%BD%D0%B0%D0%BB/]би секс анал[/url] безвозмездно! Секс и ебля !!!

  8. juli 29th, 2021 at 03:10

    louis vuitton outlet says:

    louis vuitton luggage sets louis vuitton authentic louis vuitton dallas jobs at louis vuitton louis vuitton bags macy s louis vuitton outlet sale loui vuitton sale louis Vuitton.

  9. juli 29th, 2021 at 11:45

    Juicerabo says:

    reproduced by hand, in contrast

  10. juli 29th, 2021 at 18:02

    weblog8711 says:
  11. augustus 2nd, 2021 at 10:28

    DscissDof says:

    [url=https://www.dizayn-studio.ru/]студия дизайна интерьеров[/url]
    Tegs: дизайн проект квартиры стоимость https://www.dizayn-studio.ru/dizayn/dizayn-proekt-kvartiry

    [u]дизайн интерьера квартиры[/u]
    [i]интерьер квартиры[/i]
    [b]дизайн-студия интерьеров[/b]

  12. augustus 4th, 2021 at 12:06

    Professionaldxu says:

    from a printed book, reproduction

  13. augustus 4th, 2021 at 15:50

    Visionsbk says:

    European glory, and even after

  14. augustus 6th, 2021 at 13:32

    Fidelesoms says:


  15. augustus 6th, 2021 at 17:36

    ClaytonMeday says:
  16. augustus 7th, 2021 at 17:50

    Juicerxrz says:

    Many calligraphers have acquired

  17. augustus 8th, 2021 at 07:29

    Linksyshwb says:

    At the same time, many antique

  18. augustus 9th, 2021 at 13:21

    Foamdtr says:

    handwritten synonym

  19. augustus 10th, 2021 at 01:50

    Susannew says:


  20. augustus 10th, 2021 at 12:58

    ClaytonMeday says:
  21. augustus 11th, 2021 at 05:54

    Louisdes says:

    Порно Клипс – пожалуй [url=https://classp.icu/categories/%D0%9C%D0%B8%D0%BD%D0%B5%D1%82/]скачать порно русский домашний минет[/url] самое качественное [url=https://classp.icu/]секс порно русских молодых женщин[/url] видео онлайн между тысячи сайтов! Смотреть порно безвозмездно без осточертвшей https://classp.icu/categories/%D0%98%D0%B3%D1%80%D1%83%D1%88%D0%BA%D0%B8/ рекламы!

  22. augustus 13th, 2021 at 17:35

    Dennishak says:

    Бесплатное [url=https://tubevo.icu/]самый девушки порно видео[/url] онлайн для сайте ххх туб Порнуха https://tubevo.icu/categories/%D0%91%D1%80%D0%B8%D1%82%D0%B0%D1%8F/ в НД скачать для телефон [url=https://tubevo.icu/categories/%D0%A7%D0%B0%D1%81%D1%82%D0%BD%D0%BE%D0%B5/]порно видео русское домашнее частное оргазм[/url] или халявно смотреть онлайн.

  23. augustus 14th, 2021 at 08:43

    KenCreedmoorsycle says:

    lin chi-ling
    mexico embassyV[/url]

  24. augustus 14th, 2021 at 21:25

    DramXrenpiess says:

    seungri [url=https://advanced-pdf-repair.softonic.com/]terrorist attackchannel news asia[/url]

  25. augustus 16th, 2021 at 19:00

    RogerTheda says:

    xs master editions. [url=https://vivaldiaudio.com]2020 edition preamplifiers[/url] comment from innerfidelity

  26. augustus 17th, 2021 at 08:10

    RogerTum says:
  27. augustus 17th, 2021 at 11:54

    Anthonyhaume says:
  28. augustus 17th, 2021 at 20:42

    Ginicvidere says:
  29. augustus 17th, 2021 at 23:41

    Ginicvidere says:
  30. augustus 18th, 2021 at 00:16

    Ginicvidere says:
  31. augustus 18th, 2021 at 03:03

    Ginicvidere says:
  32. augustus 18th, 2021 at 23:06

    Ginicvidere says:
  33. augustus 19th, 2021 at 00:35

    GeorgeFep says:

    Горячее [url=https://3gpono.club/]порно мастурбирует на телефон[/url] видео на телефон, ПК и планшет бесплатно в 3GP и MP4 сообразно категориям. Вы можете скачать порно [url=https://3gpono.club/categories/%D0%9C%D0%B0%D0%BC%D0%BE%D1%87%D0%BA%D0%B8/]порно ролики мамочки сыновьями[/url] сиречь посмотреть онлайн с любого https://3gpono.club/categories/%D0%93%D1%80%D1%83%D0%BF%D0%BF%D0%BE%D0%B2%D0%BE%D0%B5/ устройства!

  34. augustus 19th, 2021 at 07:20

    Ginicvidere says:
  35. augustus 20th, 2021 at 15:10

    MichaelCib says:

    Продвижение seo оптимизация с продвинутым функционалом в городе Владимир

    Лучший на сей день seo обеспечение. Это реальный комбаин в seo, решает всевозможные задачи. Работает в много-потоке в приложении есть свои прокси они считаются на сегодня лучшими.

    Идем по ссылке и зарабатываем

    [url=https://goo-gl.su/OUHL]Seo софт[/url]

  36. augustus 20th, 2021 at 17:21

    RogerTheda says:

    martin colloms’ article. [url=https://vivaldiaudio.com]stereophile’s blog pages[/url] audio-cd | stereophile.com

  37. augustus 22nd, 2021 at 14:58

    Anthonyhaume says:
  38. augustus 22nd, 2021 at 16:48

    Anthonyhaume says:
  39. augustus 22nd, 2021 at 18:38

    Anthonyhaume says:
  40. augustus 22nd, 2021 at 20:24

    Anthonyhaume says:
  41. augustus 22nd, 2021 at 22:14

    Anthonyhaume says:
  42. augustus 22nd, 2021 at 23:59

    Anthonyhaume says:
  43. augustus 23rd, 2021 at 01:46

    Anthonyhaume says:
  44. augustus 23rd, 2021 at 03:34

    Anthonyhaume says:
  45. augustus 23rd, 2021 at 05:24

    Anthonyhaume says:
  46. augustus 23rd, 2021 at 07:27

    Anthonyhaume says:
  47. augustus 23rd, 2021 at 09:19

    Anthonyhaume says:
  48. augustus 23rd, 2021 at 11:11

    Anthonyhaume says:
  49. augustus 23rd, 2021 at 13:04

    Anthonyhaume says:
  50. augustus 23rd, 2021 at 17:29

    Anthonyhaume says:
  51. augustus 23rd, 2021 at 19:49

    Anthonyhaume says:
  52. augustus 23rd, 2021 at 20:42

    RogerTum says:
  53. augustus 23rd, 2021 at 22:09

    Anthonyhaume says:
  54. augustus 23rd, 2021 at 22:35

    RogerTum says:
  55. augustus 24th, 2021 at 00:27

    RogerTum says:
  56. augustus 24th, 2021 at 02:18

    RogerTum says:
  57. augustus 24th, 2021 at 02:49

    Anthonyhaume says:
  58. augustus 24th, 2021 at 04:09

    RogerTum says:
  59. augustus 24th, 2021 at 05:09

    Anthonyhaume says:
  60. augustus 24th, 2021 at 07:28

    Holographickoa says:

    the spread of parchment.

  61. augustus 24th, 2021 at 07:28

    Anthonyhaume says:
  62. augustus 24th, 2021 at 07:51

    RogerTum says:
  63. augustus 24th, 2021 at 09:42

    RogerTum says:
  64. augustus 24th, 2021 at 09:46

    Anthonyhaume says:
  65. augustus 24th, 2021 at 11:33

    RogerTum says:
  66. augustus 24th, 2021 at 12:06

    Anthonyhaume says:
  67. augustus 24th, 2021 at 13:27

    Marvinseecy says:
  68. augustus 24th, 2021 at 14:25

    Anthonyhaume says:
  69. augustus 24th, 2021 at 15:17

    RogerTum says:
  70. augustus 24th, 2021 at 15:19

    Terrypep says:

    Мы поможем вам в лечении данных заболеваний
    Мы вынесли самые востребованные услуги на главную страницу,
    но у вас также есть возможность ознакомиться с полным перечнем предоставляемых услуг, нажав на кнопку “Показать все”. Надеемся, что вы достойно оцените качество нашего сервиса

    [url=https://medbrat.site/klinika-lechenie-alkogolizma-v-moskve/]Клиника лечение алкоголизма в москве[/url]
    [url=https://medalko.site/zhenskiy-alkogolizm-i-lechenie-v-chelyabinske/]Лечение алкоголизма клиники оренбург[/url]
    [url=https://medalko.site/category/prakticheskoe-rukovodstvo-po-lecheniyu-tabachnoy-zavisimosti/page/55/]Лечение алкоголизма в спб методы[/url]
    [url=https://medinfos.site/klinika-doverie-nizhniy-novgorod-lechenie-alkogolizma/]Клиника доверие нижний новгород лечение алкоголизма[/url]
    [url=https://medinfos.site/lecheniya-alkogolizma-cena-spb/]Лечения алкоголизма цена спб[/url]

  71. augustus 24th, 2021 at 16:42

    Anthonyhaume says:
  72. augustus 24th, 2021 at 17:10

    RogerTum says:
  73. augustus 24th, 2021 at 19:01

    Anthonyhaume says:
  74. augustus 24th, 2021 at 19:01

    Marvinseecy says:
  75. augustus 24th, 2021 at 20:51

    Marvinseecy says:
  76. augustus 24th, 2021 at 21:22

    Anthonyhaume says:
  77. augustus 24th, 2021 at 22:40

    RogerTum says:
  78. augustus 24th, 2021 at 23:39

    Anthonyhaume says:
  79. augustus 25th, 2021 at 00:21

    Terrypep says:

    Мы поможем вам в лечении данных заболеваний
    Мы вынесли самые востребованные услуги на главную страницу,
    но у вас также есть возможность ознакомиться с полным перечнем предоставляемых услуг, нажав на кнопку “Показать все”. Надеемся, что вы достойно оцените качество нашего сервиса!
    [url=https://medalko.site/category/preparaty-lechenie-tabachnoy-zavisimosti-ot/page/198/]препараты лечение табачной зависимости[/url]
    [url=https://medalko.site/alkogolizm-lechenie-v-stacionare-moskva/]Алкоголизм лечение в москве[/url]
    [url=https://medinfos.site/tag/lechenie-ot-tabachnoy-zavisimosti-moskva/page/30/]лечение от табачной зависимости москва[/url]
    [url=https://medalko.site/tag/prakticheskoe-rukovodstvo-po-lecheniyu-tabachnoy-zavisimosti/page/15/]Алкоголизм лечения по довженко[/url]
    [url=https://medinfos.site/category/lechenie-ot-tabachnoy-zavisimosti-v-penze/page/74/]лечение от табачной зависимости в пензе[/url]

    503 Service Unavailable

    Service Unavailable

    The server is temporarily unable to service your request due to maintenance downtime or capacity problems. Please try again later.

    Additionally, a 503 Service Unavailable error was encountered while trying to use an ErrorDocument to handle the request.