Skip to content

Commit ae34758

Browse files
authored
Merge pull request #964 from jaredchesebro/fix/dotenv-comments
Update env-support.md: .env.php only accepts # for comments
2 parents ae392ce + 08b8a32 commit ae34758

File tree

1 file changed

+11
-10
lines changed

1 file changed

+11
-10
lines changed

docs/advanced-usage/env-support.md

+11-10
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
-->
99
# ENV File Support
1010

11-
Config files can also be configured using [PHP Environment variables ($_ENV)](https://www.php.net/manual/en/reserved.variables.environment.php). To utilize this, create a file named `.env.php` in the root of your ExpressionEngine install.
11+
Config files can also be configured using [PHP Environment variables ($_ENV)](https://www.php.net/manual/en/reserved.variables.environment.php). To utilize this, create a file named `.env.php` in the root of your ExpressionEngine install.
1212

1313
NOTE: The `.env.php` file must be placed in same directory as the `system` directory. If you move the `system` directory above the webroot you must also move `.env.php`.
1414

@@ -31,19 +31,20 @@ This variable can now be used in your `/system/user/config.php` as illustrated b
3131
Here is an example of what it might look like to manage all your database connection settings, and Base URL in `.env.php`
3232

3333
```
34-
// .env.php
35-
36-
// URLs
34+
#.env.php
35+
#URLs
3736
BASE_URL=http://mysite.test/
3837
39-
// DATABASE SETTINGS
38+
#DATABASE SETTINGS
4039
DB_HOSTNAME=db
4140
DB_DATABASE=db
4241
DB_USERNAME=db
4342
DB_PASSWORD=db
4443
DB_PORT=3306
4544
```
4645

46+
NOTE: You must use `#` for comments within `.env.php`. Using `//` will result in your `.env.php` being unable to be read.
47+
4748
```
4849
// system/user/config.php
4950
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
@@ -53,7 +54,7 @@ $config['save_tmpl_files'] = 'y';
5354
$config['base_url'] = $_ENV['BASE_URL'];
5455
$config['site_url'] = $config['base_url'];
5556
56-
$config['app_version'] = '7.2.0';
57+
$config['app_version'] = '7.5.8';
5758
$config['encryption_key'] = 'bb748b72de235352315122d00';
5859
$config['session_crypt_key'] = '985796e4444444563463e2c80242';
5960
@@ -83,15 +84,15 @@ The site short name can be accessed in the code using `$GLOBALS['assign_to_confi
8384
The below example demonstrates this approach, assuming you have 2 MSM sites with short names of `default_site` and `second_site`
8485

8586
```
86-
// .env.php
87-
// SITE-SPECIFIC SETTINGS
87+
#.env.php
88+
#SITE-SPECIFIC SETTINGS
8889
default_site.BASE_PATH=/home/sites/mysite.test/
8990
default_site.BASE_URL=http://mysite.test/
9091
9192
second_site.BASE_PATH=/home/sites/anothersite.test/
9293
second_site.BASE_URL=http://anothersite.test/
9394
94-
// DATABASE SETTINGS
95+
#DATABASE SETTINGS
9596
DB_HOSTNAME=db
9697
DB_DATABASE=db
9798
DB_USERNAME=db
@@ -110,7 +111,7 @@ $config['base_url'] = $_ENV[$GLOBALS['assign_to_config']['site_name'] . '.' . 'B
110111
111112
$config['site_url'] = $config['base_url'];
112113
113-
$config['app_version'] = '7.2.0';
114+
$config['app_version'] = '7.5.8';
114115
$config['encryption_key'] = 'bb748b72de235352315122d00';
115116
$config['session_crypt_key'] = '985796e4444444563463e2c80242';
116117

0 commit comments

Comments
 (0)