php - Expression Engine: Synchronising development and live environments -


i have read post seem quite old (2008) , hoping might have more elegant solution.

i know how expression engine developers working local test , live environment workflow.

i have expression engine 2.8.1 running on live environment (debian web server). develop channels, channel fields, themes , other content configurations in local test environment on laptop (mamp server, virtualbox vm, whatever). once happy push changes live server.

the tricky part specific changes exist both in database , file system. further more don’t want push whole database live server paths / urls , other configuration options different each.

i using file based templates makes part of process easier database configurations still problem. there simple clean way export / import content configuration tables between these environments?

any , appreciated.

most people using variety of plugins synchronisation, including low variables global variables files , snippet sync same snippets.

as syncing database changes there no synchronisation option sync channel entries etc. write plugin execute sql directory have code changes in sql..

if have ability have prod , staging (test) server communicate each other setup database level replication across 2 advise against mean changes in prod/staging replicated on other server.

yu can setup multiple environments expression engine bit of slight code modification. example use various configs different environments, file system structure similar this:

  • system
  • themes
  • images
  • config
    • config.env.php
    • config.local.php
    • config.prod.php
    • config.staging.php
    • config.master.php

in config.env.php:

<?php /* environment declaration */ if ( ! defined('env')) {     switch ($_server['http_host'])      {         // === production environments         case 'host_name' :             define('env', 'prod');             define('env_full', 'production');             define('env_debug', false);             define('env_type', 'production');         break;         // === staging environments         case 'host_name' :             define('env', 'stage');             define('env_full', 'staging');             define('env_debug', false);             define('env_type', 'staging');         break;         // === default local         default :             define('env', 'local');              define('env_full', 'local');              define('env_debug', false);              define('env_type', 'local');          break;     } } /* end of file config.env.php */ /* location: ./config/config.env.php */ 

then in each of config.{environment}.php files can things similar this: config.prod.php

<?php if ( ! defined('basepath')) exit('no direct script access allowed');  /**  * production config overrides & db credentials  *   * our database credentials , environment-specific overrides  *   */  // safeguard error_reporting(e_all); @ini_set('display_errors', 1);  $env_db['hostname'] = 'dbhost'; $env_db['username'] = 'dbuser'; $env_db['password'] = 'dbpassword'; $env_db['database'] = 'dbname';   /* end of file config.prod.php */ /* location: ./config/config.prod.php */ 

you put config overrides in environment configs well. have added sample config.master.php pastebin, here: http://pastebin.com/t9l2ef1e

no last thing add bit of code /system/expressionengine/config/config.php , database.php files.

fistly /system/expressionengine/config/config.php file, need add following code (be warned file paths may different may need update following code suit needs)

add bottom of file:

require(realpath(dirname(__file__) . '/../../../config/config.master.php')); 

then in /system/expressionengine/config/database.php remove db settings (so have vanilla file) , add in config path, so:

$active_group = 'expressionengine'; $active_record = true;

$db['expressionengine']['dbdriver'] = 'mysql'; $db['expressionengine']['dbprefix'] = 'exp_'; $db['expressionengine']['pconnect'] = false; $db['expressionengine']['swap_pre'] = 'exp_'; $db['expressionengine']['db_debug'] = true; $db['expressionengine']['cache_on'] = false; $db['expressionengine']['autoinit'] = false; $db['expressionengine']['char_set'] = 'utf8'; $db['expressionengine']['dbcollat'] = 'utf8_general_ci';

require(realpath(dirname(file) . '/../../../config/config.master.php'));

/* end of file database.php / / location: ./system/expressionengine/config/database.php */

that should allow use same file base , still able deploy dev, staging , production no issues via source control.

i have in fact set few of clients , working flawlessly. fyi may need pay ee modules facilitate saving files variables , snippets.


Comments

Popular posts from this blog

PHPMotion implementation - URL based videos (Hosted on separate location) -

javascript - Using Windows Media Player as video fallback for video tag -

c# - Unity IoC Lifetime per HttpRequest for UserStore -