-
Notifications
You must be signed in to change notification settings - Fork 0
/
App.php
51 lines (41 loc) · 1.02 KB
/
App.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
<?php
class App {
public $db;
private static $instance;
private $router;
private $config;
public static function GetApp(){
if(self::$instance == null){
self::$instance = new App();
}
return self::$instance;
}
public function getSetting($name){
return isset($this->config[$name]) ? $this->config[$name] : "";
}
public function getRouter(){
return $this->router;
}
private function parseConfig(){
$this->config = parse_ini_file('config.ini');
}
private function initDb(){
$this->db = new mysqli(
$this->getSetting('dbHost'),
$this->getSetting('dbUser'),
$this->getSetting("dbPassword"),
$this->getSetting("dbName")
);
$this->db->set_charset("utf8");
}
public function launch(){
$this->parseConfig();
$this->initDb();
$this->router = new Router();
$controller = $this->router->getController();
$method = $this->router->getAction();
$instance = new $controller();
print $instance->$method();
}
}
?>