Multiple Environment Configuration

Use different configurations based on where your site is running.

The right configurations at the right time#

It's easy to define different configurations for the different environments your site is running on. For example, you are running a copy of your site on your local computer, we'll call that the staging area, and your running another copy of your site on your hosted web server, will call that the production area. The two sites may have different database credential configs and your production site may always run on https while, it's not possible to run your staging site via an https connection.

Supporting the multiple environments is really very simple.

By default our general configs are defined in enact/config/config.php and our default database credentials are defined in enact/config/db.php.

To extend these with different configurations you will simply create a file that matches the $_SERVER['SERVER_NAME'] directive, which is equal to the domain name your site is running from. So if your staging site is being run from yoursite.localhost then you will create two new configuration files at enact/config/yoursite.localhost.db.php and enact/config/yoursite.localhost.config.php and specify whatever configurations you want to override.

Sample enact/config/yoursite.localhost.db.php:#

return Array(
    'DB_DB' => 'STAGING_DB',
    'DB_HOST' => 'localhost',
    'DB_USER' => 'root',
    'DB_PASSWORD' => 'password',
    'DB_PREFIX' => 'enact_'

Sample enact/config/yoursite.localhost.config.php:#

return Array(
    'forceSecureRequests' => false

And thats it, your site is now setup to support multiple environments!