-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathindex.php
50 lines (45 loc) · 1.18 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
<?php
class ZooHelper
{
public function __construct($uri)
{
$this->_init($uri);
$this->_autoload();
$this->_bootstrap();
}
/**
* 初始化
* @param $uri
*/
private function _init($uri)
{
error_reporting(0);
define('PATH_ROOT', str_replace('\\', '/', dirname(__FILE__)));
define('VERSION', '1.0');
list($module, $method) = explode('/', trim($uri, '/'));
define('MODULE', $module ?: 'index');
define('METHOD', $method ?: 'index');
date_default_timezone_set('prc');
}
/**
* 自动加载
*/
private function _autoload()
{
spl_autoload_register(function ($classname) {
$config = ['ctl' => 'control', 'mdl' => 'model', 'lib' => 'library'];
$dir = $config[substr($classname, 0, 3)];
$file = sprintf('%s/%s/%s.php', PATH_ROOT, $dir, $classname);
include_once $file;
});
}
/**
* 运行框架
*/
private function _bootstrap()
{
$class = sprintf('ctl%s', ucfirst(MODULE));
call_user_func([new $class(), METHOD]);
}
}
new ZooHelper($_SERVER['SCRIPT_URL']);