Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
62 changes: 61 additions & 1 deletion docs/advanced-usage/env-support.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,67 @@ $config['save_tmpl_files'] = 'y';
$config['base_url'] = $_ENV['BASE_URL'];
$config['site_url'] = $config['base_url'];

$config['app_version'] = '7.0.0-rc.1';
$config['app_version'] = '7.2.0';
$config['encryption_key'] = 'bb748b72de235352315122d00';
$config['session_crypt_key'] = '985796e4444444563463e2c80242';

$config['database'] = array(
'expressionengine' => array(
'hostname' => $_ENV['DB_HOSTNAME'],
'database' => $_ENV['DB_DATABASE'],
'username' => $_ENV['DB_USERNAME'],
'password' => $_ENV['DB_PASSWORD'],
'dbprefix' => 'exp_',
'char_set' => 'utf8mb4',
'dbcollat' => 'utf8mb4_unicode_ci',
'port' => $_ENV['DB_PORT'],
),
);
$config['show_ee_news'] = 'y';

// EOF
```

## MSM Example

If your ExpressionEngine installation is hosting multiple sites, you can specify different values for MSM sites configuiration by using site short name as prefix.

Th site short name can be accessed in the code using `$GLOBALS['assign_to_config']['site_name']` variable.

The below example demonstrates this approach, assuming you have 2 MSM sites with short names of `default_site` and `second_site`

```
# .env.php

# SITE-SPECIFIC SETTINGS

default_site.BASE_PATH=/home/sites/mysite.test/
default_site.BASE_URL=http://mysite.test/

second_site.BASE_PATH=/home/sites/anothersite.test/
second_site.BASE_URL=http://anothersite.test/

# DATABASE SETTINGS
# # # # # # # # # # # #
DB_HOSTNAME=db
DB_DATABASE=db
DB_USERNAME=db
DB_PASSWORD=db
DB_PORT=3306
```

```
// system/user/config.php
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

$config['save_tmpl_files'] = 'y';

$config['base_path'] = $_ENV[$GLOBALS['assign_to_config']['site_name'] . '.' . 'BASE_PATH'];
$config['base_url'] = $_ENV[$GLOBALS['assign_to_config']['site_name'] . '.' . 'BASE_URL'];

$config['site_url'] = $config['base_url'];

$config['app_version'] = '7.2.0';
$config['encryption_key'] = 'bb748b72de235352315122d00';
$config['session_crypt_key'] = '985796e4444444563463e2c80242';

Expand Down