-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathApp.php
38 lines (30 loc) · 934 Bytes
/
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
<?php
namespace BLEST\BLEST;
require_once __DIR__ . '/include/polyfill.php';
require_once __DIR__ . '/Router.php';
require_once __DIR__ . '/HttpServer.php';
class App extends Router {
private $options;
public function __construct($options = array()) {
parent::__construct($options);
$this->options = $options ?: array();
}
public function run() {
// $routes = $this->routes;
$options = $this->options;
$handler = function(array $requests, array $context = []) {
return $this->handle($requests, $context);
};
$server = new HttpServer($handler, $options);
$args = func_get_args();
call_user_func_array(array($server, 'run'), $args);
}
}
$blestAppInstance = null;
function app() {
global $blestAppInstance;
if ($blestAppInstance === null) {
$blestAppInstance = new App();
}
return $blestAppInstance;
}