Drupal - How do I programmatically change settings to simplify sharing of config changes?

At the risk of opening up a whole ugly can of worms on Drupal's current lack of config management, I am just going to point towards the D8 Configuration Management Initiative as the over-arching response to this.

To answer your more specific question about block/layout management, there are a few attempts at addressing this using Features/Features Extra:

Layout with Context or Panels or Display Suite

Better blocks with Boxes or Bean or Bricks


You can hardcode any variable (you know, from variable_get()/-set()/-delete()) in your settings.php.

E.g, mentioned in that file, the "site name".

$conf['site_name'] = 'My Drupal site';

This only works for variables, so is of (very) limited use. As @nicoz mentions: a can of worms.

Places where I use this, though:

  • A test.example.com/settings.php: $conf['site_name'] = 'WARNING TEST ENVIRONMENT';
  • Quick, custom modules. It saves you from developing settings-pages that will only be visited once while avoiding harcoded values inside that module.
  • Different API-endpoints, keys, etc in various environments: You want to avoid hitting that production-payment-platform when developing on localhost. Or sending out 10.000 "W000t it works" mails to all your clients. :)

But for sharing with your co-workers this might be too limited.