-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdotenv.php
39 lines (36 loc) · 1.22 KB
/
dotenv.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
<?php
require __DIR__ . '/vendor/autoload.php';
/**
* Immutability refers to if Dotenv is allowed to overwrite existing environment variables.
* If you want Dotenv to overwrite existing environment variables,
* use createMutable instead of createImmutable
*/
$dotenv = Dotenv\Dotenv::createImmutable(__DIR__);
//$dotenv = Dotenv\Dotenv::createMutable(__DIR__);
if (getenv('CONFIG_ENV') != "production") {
$dotenv->load();
/**
* Load a second file, can be relative or absolute
* Should be in a non web accessible folder
* Specify filename, default is .env
*/
//$dotenv = Dotenv\Dotenv::createMutable(__DIR__."/secure_folder","elephpant");
//$dotenv->load();
//echo getenv('FAVORITE_COLOR');
}
$dotenv->required(['DB_SERVER', 'DB_NAME', 'DB_USERNAME', 'DB_PASSWORD']);
header("Content-Type: text/plain");
var_dump(getenv('S3_BUCKET'));
try {
$db = new PDO(
"mysql:host=".getenv('DB_SERVER')
. ";dbname=".getenv('DB_NAME'),
getenv('DB_USERNAME'),
getenv('DB_PASSWORD')
);
$db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
} catch (Exception $e) {
echo $e->getMessage();
exit;
}
var_dump($db->query("SELECT * FROM custom_vars")->fetchAll());