Dev and Prod, same config, different database

Permalink 1 user found helpful
If you need a different development and production database with the same installation in concrete >=5.7 (inspired from version 5.6http://concrete5tricks.com/blog/dev-stage-prod-same-config):...

1. Step
Add a new virtual host (development.example.com) to your web-server config with the same docroot-directory of your production-directory

2. Step
Duplicate your existing database… (or regulary with a duplication-script in a cron job)

3. Step
Clear cache (or regulary via the duplication-script)

4. Step
Simple add the following code to your installation /application/config/database.php:

<?php
if ( $_SERVER['SERVER_NAME'] == "development.example.com" ) {
    $ database_default = "Development";
    }
    else {
    $ database_default = "Production";
    }
return array(
    'default-connection' => $database_default,
    'connections' => array(
        'Production' => array(
            'driver' => 'c5_pdo_mysql',
            'server' => 'localhost',
            'database' => 'concrete_production',
            'username' => 'concrete_prod-user',


Hope this helps…

Watch out: added files to your dev-installation are not shown in your prod! Always add it to the prod-installation and sync your database.

olafpeter
View Replies:
mnakalay replied on at Permalink Reply
mnakalay
That's great.

You should post it as a how-to in the how-to section so it doesn't get lost in the forum.