Skip to content

Commit adb6332

Browse files
authored
Merge pull request #526 from ExpressionEngine/feature/7.x/msm-env-files
example using .env with MSM
2 parents e1bc939 + 4cbe5f1 commit adb6332

File tree

1 file changed

+61
-1
lines changed

1 file changed

+61
-1
lines changed

docs/advanced-usage/env-support.md

Lines changed: 61 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,67 @@ $config['save_tmpl_files'] = 'y';
5050
$config['base_url'] = $_ENV['BASE_URL'];
5151
$config['site_url'] = $config['base_url'];
5252
53-
$config['app_version'] = '7.0.0-rc.1';
53+
$config['app_version'] = '7.2.0';
54+
$config['encryption_key'] = 'bb748b72de235352315122d00';
55+
$config['session_crypt_key'] = '985796e4444444563463e2c80242';
56+
57+
$config['database'] = array(
58+
'expressionengine' => array(
59+
'hostname' => $_ENV['DB_HOSTNAME'],
60+
'database' => $_ENV['DB_DATABASE'],
61+
'username' => $_ENV['DB_USERNAME'],
62+
'password' => $_ENV['DB_PASSWORD'],
63+
'dbprefix' => 'exp_',
64+
'char_set' => 'utf8mb4',
65+
'dbcollat' => 'utf8mb4_unicode_ci',
66+
'port' => $_ENV['DB_PORT'],
67+
),
68+
);
69+
$config['show_ee_news'] = 'y';
70+
71+
// EOF
72+
```
73+
74+
## MSM Example
75+
76+
If your ExpressionEngine installation is hosting multiple sites, you can specify different values for MSM sites configuiration by using site short name as prefix.
77+
78+
Th site short name can be accessed in the code using `$GLOBALS['assign_to_config']['site_name']` variable.
79+
80+
The below example demonstrates this approach, assuming you have 2 MSM sites with short names of `default_site` and `second_site`
81+
82+
```
83+
# .env.php
84+
85+
# SITE-SPECIFIC SETTINGS
86+
87+
default_site.BASE_PATH=/home/sites/mysite.test/
88+
default_site.BASE_URL=http://mysite.test/
89+
90+
second_site.BASE_PATH=/home/sites/anothersite.test/
91+
second_site.BASE_URL=http://anothersite.test/
92+
93+
# DATABASE SETTINGS
94+
# # # # # # # # # # # #
95+
DB_HOSTNAME=db
96+
DB_DATABASE=db
97+
DB_USERNAME=db
98+
DB_PASSWORD=db
99+
DB_PORT=3306
100+
```
101+
102+
```
103+
// system/user/config.php
104+
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
105+
106+
$config['save_tmpl_files'] = 'y';
107+
108+
$config['base_path'] = $_ENV[$GLOBALS['assign_to_config']['site_name'] . '.' . 'BASE_PATH'];
109+
$config['base_url'] = $_ENV[$GLOBALS['assign_to_config']['site_name'] . '.' . 'BASE_URL'];
110+
111+
$config['site_url'] = $config['base_url'];
112+
113+
$config['app_version'] = '7.2.0';
54114
$config['encryption_key'] = 'bb748b72de235352315122d00';
55115
$config['session_crypt_key'] = '985796e4444444563463e2c80242';
56116

0 commit comments

Comments
 (0)