Instantly share code, notes, and snippets.

Embed
What would you like to do?
Use FocusLab Config with MSM
  1. In your main site's index.php file (and also your admin.php and system/index.php files), add the following lines just below the custom config values section:

    define('FLC_DOCROOT', $_SERVER['DOCUMENT_ROOT']);
    define('FLC_PATH', $_SERVER['DOCUMENT_ROOT'].'/config');
  2. In config.master.php, update the lines 94 and 235 as follows:

    $base_path = FLC_DOCROOT;
    
    require FLC_PATH . '/config.' . ENV . '.php';
  3. In system/expressionengine/config/config.php and system/expressionengine/config/database.php, change the require lines as follows:

    require FLC_PATH . '/config.master.php';
  4. In each of your MSM sites' index.php files, add the lines from #1 above, but make sure to change FLC_PATH to your main site's config folder.

@cottonhen

This comment has been minimized.

cottonhen commented Feb 5, 2013

Hi there! I've done as you suggest but now when I go to the CP www.mysite.com/admin.php i get an error beacesue the costants are not defined (FLC_DOCROOT and FLC_PATH are defined in index.php) any idea?

@akuzemchak

This comment has been minimized.

Owner

akuzemchak commented Mar 27, 2013

Sorry, never saw this comment. Just updated the gist to say that the lines in step 1 need to also be defined in admin.php and system/index.php.

@jdaining

This comment has been minimized.

jdaining commented Oct 26, 2013

Thanks for this!

@Jameswilsonjennings

This comment has been minimized.

Jameswilsonjennings commented Nov 12, 2014

Hi, thanks for this! working fine for the main site. With point (4), can you give an example, do you mean the master config folder or the ee config folder. I've tried just hardcoding both like:
define('FLC_PATH', '/var/www/vhosts/mainsite.com/httpdocs/config'); But no child msm site loads.

Regards,

James.

@nachopants

This comment has been minimized.

nachopants commented May 30, 2016

Hi guys,

I've set this up (v3.3.2) but seem to be getting a bizarre issue.

Fatal error: Cannot redeclare class EE_Benchmark in /var/www/html/www.heffron-it.com.au/system/ee/legacy/core/Benchmark.php on line 30

Has anyone else run into this, or does this solution no longer work?

EDIT [SOLVED]

$env_config['subclass_prefix'] = 'EE_'; is required

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment