-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.php
53 lines (47 loc) · 1.12 KB
/
index.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
<?php
//Api Center
//2020.10.17
//youranreus
header('Content-Type:application/json; charset=utf-8');
header('Access-Control-Allow-Origin:*');
header('Access-Control-Allow-Headers:*');
include 'vendor/autoload.php';
use App\Core\HTTP;
use App\Core\X;
use App\Conf\Conf;
//init DB
if (is_file('./.env')) {
$env = parse_ini_file('./.env', true); //解析env文件,name = PHP_KEY
foreach ($env as $key => $val) {
$name = $key;
if (is_array($val)) {
foreach ($val as $k => $v) { //如果是二维数组 item = PHP_KEY_KEY
$item = $name . '_' . strtoupper($k);
putenv("$item=$v");
}
} else {
putenv("$name=$val");
}
}
}
Conf::setDB([getenv('DB_servername'),getenv('DB_username'),getenv('DB_password'),getenv('DB_dbname')]);
$X = new X();
if(!$X->DBCheck())
{
die(json_encode(['msg'=>'数据库信息初始化失败']));
}
//set debug mode
if(getenv('DEBUG'))
{
error_reporting(0);
}
else
{
error_reporting(E_ALL);
}
//start App
$App = new HTTP();
//active Router Rule
$X->activeRouterRule();
//respond
$App->throw();