-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbootstrap.php
90 lines (70 loc) · 2.34 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
79
80
81
82
83
84
85
86
87
88
89
90
<?php
declare(strict_types=1);
require_once "vendor/autoload.php";
use App\Core\Http\AppRequest;
use App\Core\Http\CorsConfig;
use App\Core\Services\JWTService;
use App\Core\Services\StorageSystem;
use Dotenv\Dotenv;
use Illuminate\Database\Capsule\Manager as Capsule;
/* ------------------------------------------------------------------------------------------------------------------ */
/*
* Load .ENV support
*/
$dotenv = Dotenv::createImmutable(__DIR__);
$dotenv->load();
/* ------------------------------------------------------------------------------------------------------------------ */
/*
* Init Laravel Eloquent (Database component)
*/
$capsule = new Capsule();
$capsule->addConnection([
"driver" => "mysql",
"host" => $_ENV["DB_HOST"],
"database" => $_ENV["DB_NAME"],
"username" => $_ENV["DB_USERNAME"],
"password" => $_ENV["DB_PASSWORD"],
"charset" => "utf8",
"collation" => "utf8_unicode_ci",
"prefix" => "",
]);
$capsule->setAsGlobal();
$capsule->bootEloquent();
/* ------------------------------------------------------------------------------------------------------------------ */
/*
* Load request handing config
*/
CorsConfig::enableCORS();
AppRequest::mergeAxiosRequest();
/* ------------------------------------------------------------------------------------------------------------------ */
/*
* JWT config
*/
JWTService::init($_ENV["JWT_SECRET"], $_ENV["JWT_AUDIENCE"], $_ENV["JWT_AUDIENCE"]);
/* ------------------------------------------------------------------------------------------------------------------ */
/*
* Pagination
*/
const PAGE_SIZE = 30;
/* ------------------------------------------------------------------------------------------------------------------ */
/*
* Load file upload config
*/
StorageSystem::setAdapter(__DIR__ . "/public/uploads");
/* ------------------------------------------------------------------------------------------------------------------ */
/* set debug as false for production env */
/* debug will disable auth token validation */
if (isset($_ENV["DEBUG"])) {
if ($_ENV["DEBUG"] == "true") {
define("DEBUG", true);
} else {
define("DEBUG", false);
}
} else {
define("DEBUG", false);
}
/* ------------------------------------------------------------------------------------------------------------------ */
function logme($data): void
{
error_log(print_r($data, true));
}