-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcreator.php
More file actions
50 lines (41 loc) · 1.39 KB
/
creator.php
File metadata and controls
50 lines (41 loc) · 1.39 KB
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
<?php
define('ROOT_PATH', __DIR__);
define('DS', DIRECTORY_SEPARATOR);
define('DATA_PATH', ROOT_PATH.DS.'data');
define('OUTPUT_PATH', DATA_PATH.DS.'output');
require_once ROOT_PATH.'/Autoloader.php';
class Creator {
private static $_config = [];
public static function run() {
self::init();
self::create();
}
public static function create() {
try {
$config = self::getConfig();
$database = new \detailedDesign\DatabaseParser($config['host'], $config['port'], $config['database'], $config['username'], $config['password'], $config['charset']);
$desc = $database->getDesc();
$apiDoc = new \detailedDesign\DocumentCreator($desc, $config);
$apiDoc->create();
} catch (Exception $ex) {
echo "create error:\n".$ex->getMessage();
}
}
public static function getConfig() {
if (!empty(self::$_config)) {
return self::$_config;
}
$content = file_get_contents(ROOT_PATH.DS.'config.json');
self::$_config = json_decode($content, true);
return self::$_config;
}
public static function init() {
if (!file_exists(DATA_PATH)) {
mkdir(DATA_PATH);
}
if (!file_exists(OUTPUT_PATH)) {
mkdir(OUTPUT_PATH);
}
}
}
Creator::run($argv);