-
Notifications
You must be signed in to change notification settings - Fork 2
/
setup.php
54 lines (49 loc) · 1.26 KB
/
setup.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
<?php
/**
* Environment setup file
*/
// Enable composer autoloading.
require_once( __DIR__ . '/vendor/autoload.php' );
// ===========================
// SETUP ENVIRONEMNT VARIABLES
// ===========================
$required_envs = [
'DB_NAME',
'DB_USER',
'DB_PASSWORD',
'AUTH_KEY',
'SECURE_AUTH_KEY',
'LOGGED_IN_KEY',
'NONCE_KEY',
'AUTH_SALT',
'SECURE_AUTH_SALT',
'LOGGED_IN_SALT',
'NONCE_SALT',
'WP_REDIS_HOST',
'WP_REDIS_DB',
];
$root_dir = dirname( __FILE__ );
// .env is located in the project root in local environment.
if ( file_exists( $root_dir . '/.env' ) ) {
define( 'WP_LOCAL_DEV', true );
}
else {
define( 'WP_LOCAL_DEV', false );
// Step one level up
$root_dir = dirname( __FILE__ ) . '/../..';
}
// Use Dotenv to set required environment variables and load the .env file.
if ( class_exists( 'Dotenv\Dotenv' ) && file_exists( $root_dir . '/.env' ) ) {
$dotenv = new Dotenv\Dotenv( $root_dir );
$dotenv->load();
try {
$dotenv->required( $required_envs );
} catch ( Exception $e ) {
// @codingStandardsIgnoreStart
die( $e->getMessage() );
// @codingStandardsIgnoreEnd
}
} else {
die( 'Environment variables not found!' );
}
define( 'SETUP_DONE', true );