This repository has been archived by the owner on May 13, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbootstrap.php
78 lines (60 loc) · 1.95 KB
/
bootstrap.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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
<?php
/* Load vendor and project libraries */
require(dirname(__FILE__) . '/vendor/autoload.php');
/* Load .env File */
$dotenv = new Dotenv\Dotenv(__DIR__);
$dotenv->load();
if (empty($dotenv->load())) {
error_reporting(-1);
ini_set('display_errors', 'On');
}
$dotenv->required('SITE_PATH');
// Site url
define('SITE_PATH', getenv('SITE_PATH'));
// Global Variables
$GLOBALS['SITE_PATH'] = SITE_PATH;
$GLOBALS['USER_ID'] = '';
/* Debug Mode */
if (getenv('DEBUG_MODE') == 'true') {
define('DEBUG_MODE', true);
} else {
define('DEBUG_MODE', false);
}
/* Timezone */
if (getenv('TIME_ZONE') == null) {
define('TIME_ZONE', 'UTC');
date_default_timezone_set(TIME_ZONE);
} else {
define('TIME_ZONE', getenv('TIME_ZONE'));
date_default_timezone_set(TIME_ZONE);
}
/* Database Drivers */
$dotenv->required('DB_DRIVER')->allowedValues(['sqlite', 'mysql']);
define('DB_DRIVER', getenv('DB_DRIVER'));
/* MYSQL Database Settings */
if (DB_DRIVER == 'mysql') {
$dotenv->required(['DB_HOST', 'DB_NAME', 'DB_USER', 'DB_PASS']);
define('DB_HOST', getenv('DB_HOST'));
define('DB_NAME', getenv('DB_NAME'));
define('DB_USER', getenv('DB_USER'));
define('DB_PASS', getenv('DB_PASS'));
}
// Init dependency injection container
if (DEBUG_MODE) {
$container_config = array_merge(
require(__DIR__ . '/config/services.php'),
require(__DIR__ . '/config/Application/Auth.php'),
require(__DIR__ . '/config/Application/Dashboard.php'),
require(__DIR__ . '/config/Application/User.php')
);
unset($container_config['notFoundHandler']);
unset($container_config['errorHandler']);
} else {
$container_config = array_merge(
require(__DIR__ . '/config/services.php'),
require(__DIR__ . '/config/Application/Auth.php'),
require(__DIR__ . '/config/Application/Dashboard.php'),
require(__DIR__ . '/config/Application/User.php')
);
}
$container = new \Slim\Container($container_config);