-
-
Notifications
You must be signed in to change notification settings - Fork 2
/
config.php
47 lines (40 loc) · 1.1 KB
/
config.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
<?php
namespace Lifyzer\Api;
use Dotenv\Dotenv;
use Phpfastcache\CacheManager;
use Phpfastcache\Config\ConfigurationOption;
$requiredEnvFields = [
'DB_HOST',
'DB_USER',
'DB_PWD',
'DB_NAME',
'DEBUG_MODE',
'CACHE',
'ENCRYPTION_KEY_IV',
'SENDER_EMAIL_NAME',
'SENDER_EMAIL_ID',
'SENDER_EMAIL_PASSWORD',
'SWISS_FOOD_KEY',
'USA_FOOD_KEY',
'URL_OPEN_FOOD_NAME_API',
'URL_OPEN_FOOD_BARCODE_API',
'URL_USA_FOOD_API',
'URL_SWISS_FOOD_API'
];
// Setup cache config
CacheManager::setDefaultConfig(
new ConfigurationOption(
[
'path' => dirname(__DIR__) . '/cache'
]
)
);
$env = Dotenv::createImmutable(__DIR__);
$env->load();
$env->required($requiredEnvFields)->notEmpty();
// First, convert "true/false" string from phpdotenv to boolean
$debugMode = filter_var($_ENV['DEBUG_MODE'], FILTER_VALIDATE_BOOLEAN);
$cacheStatus = filter_var($_ENV['CACHE'], FILTER_VALIDATE_BOOLEAN);
define('DEBUG_MODE', $debugMode);
define('CACHE_ENABLED', $cacheStatus);
date_default_timezone_set('UTC');