I couldn't find answer from previous questions nor drupal.org/pantheon.io.

There isn't a settings.php if I clone the repository from pantheon.io nor a settings.local.php.

If I create a settings.local.php file, it still thinks it's a fresh install and redirects to install.php, which means it doesn't recognize that file.

How do I use the settings.local.php file?

Naturally, all works if I create a settings.php file.

Can't I just create settings.php for the development site and add a reference to it in the .gitignore file to avoid it will be pushed on the remote repository?

  • .gitignore in Drupal core already ignores settings.php file by default. If the repo doesn't have a settings.php, it should be safe to create one. It will not be added to the repo on git add.
    – AjitS
    Commented May 8, 2017 at 6:35
  • Okay, I'll try to keep that in mind. However, it is still a question that how settings.local.php could be used? Commented May 8, 2017 at 10:59
  • You will need to still edit settings.php to write a include statement for the settings.local.php as described on the answer.
    – AjitS
    Commented May 9, 2017 at 6:04

2 Answers 2


When installing Drupal, you need to copy the example.settings.php file in settings.php. After Drupal is installed, you need to include the following code in the settings.php file.

if (file_exists(DRUPAL_ROOT . '/' . conf_path() . '/settings.local.php')) {
  include DRUPAL_ROOT . '/' . conf_path() . '/settings.local.php';
  • This answer may be outdated. The combination DRUPAL_ROOT and conf_path() may return the wrong value and then prevents the settings local file from being loaded. @mbomb007's answer below seems to fix this.
    – leymannx
    Commented Jun 21, 2019 at 13:40
  • And to include this it is supposed to be appended to settings.php? If it has same variables that is in settings.php then it would override them to match local preferences. Commented Oct 22, 2019 at 7:49

There is an active issue for this that has already been committed to 8.x and 9.x, and it's being backported to 7.x. It adds the code in settings.php to include settings.local.php.

The code in the patch makes some improvements on the code in the other answer.

// Include a local settings file if it exists.
$local_settings = dirname(__FILE__) . '/settings.local.php';
if (is_readable($local_settings)) {
  include $local_settings;

See Add inclusion of a settings.local.php file in settings.php.

Additional Notes:

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.