You are here


Include a local Drupal settings file for environment configuration and overrides

Submitted by Oliver Davies on 20 December, 2014 - 12:16

At the bottom of settings.php, add the following code:

$local_settings = __DIR__ . '/settings.local.php';
if (file_exists($local_settings)) {
  include $local_settings;

This allows for you to create a new file called settings.local.php within a sites/* directory (the same place as settings.php), and this will be included as an extension of settings.php. You can see the same technique being used within Drupal 8's default.settings.php file.

Include environment-specific settings files on Pantheon

Submitted by Oliver Davies on 27 November, 2014 - 17:24

I was recently doing some work on a site hosted on Pantheon and came across an issue, for which part of the suggested fix was to ensure that the $base_url variable was explicitly defined within settings.php (this is also best practice on all Drupal sites).

The way that was recommended was by using a switch() function based on Pantheon's environment variable. For example:

How to fix Vagrant Loading the Wrong Virtual Machine

Submitted by Oliver Davies on 6 October, 2014 - 08:59

A few times recently, I've had instances where Vagrant seems to have forgotten which virtual machine it's supposed to load, probably due to renaming a project directory or the .vagrant directory being moved accidentally. Here are the steps that I took to fix this and point Vagrant back at the correct VM.

git format-patch is your Friend

Submitted by Oliver Davies on 21 May, 2014 - 11:00

The Problem

As an active contributor to the Drupal project, I spend a lot of time working with other peoples’ modules and themes, and occassionally have to fix a bug or add some new functionality.

In the Drupal community, we use a patch based workflow where any changes that I make get exported to a file detailing the differences. The patch file (*.patch) is attached to an item in an issue queue on, applied by the maintainer to their local copy of the code and reviewed, and hopefully committed.


Subscribe to Blog