Home

Database Configuration Management

Wouldn't it be easy to have a single environment configuration for all your SilverStripe sites without having to reconfigure each one individually? Wouldn't it be great not to have to change environment settings when you push your site from development to live servers? This is easy to achieve using the SilverStripe "ConfigureFromEnv" script.

To set this up, remove your $databaseConfig line from your site _config.php and add:

mysite/_config.php

Then create a new _ss_environment.php file. This can live in your web root, in it's parent or it's parent parent folder. Define the following constants:

_ss_enviroment.php

Now your _config.php file only needs one setting, a $database parameter that points SilverStripe to the correct database for this server!

About the Author

Name: Hamish Campbell

Website: http://polemic.net.nz/

Hamish is a web developer for Opus International Consultants in New Zealand. He creates tools for managing data online, with a particular interest in geographical information systems. He is also an active contributor to the SilverStripe open source project. You can find Hamish on twitter (@polemic) or catch him at his ever-neglected web home http://polemic.net.nz/.

Comments (2)

  • Thanks for that snippet, Hamish. When different people work on a site using SVN, we always had problems submitting the _config.php, because it carried the local db settings.

    Posted by Roland Lehmann, 10/05/2010 9:40am (3 months ago)

  • definitely a good way for developing a massive numbers of websites.
    Useful environmental configurarion tutorial

    Posted by alex, 18/02/2010 6:30pm (5 months ago)

RSS feed for comments on this page RSS feed for all comments

Post your comment