forked from mylxsw/FocusPHP-Blog
/
index.php
40 lines (33 loc) · 1.26 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
<?php
/**
* FocusPHP
*
* @link http://aicode.cc/
* @copyright 管宜尧 <mylxsw@aicode.cc>
* @license http://www.opensource.org/licenses/mit-license.php MIT (see the
* LICENSE file)
*/
require __DIR__ . '/vendor/autoload.php';
define('BASE_PATH', __DIR__ . '/src');
$basicContainer = new \Focus\BasicContainer(__DIR__
. '/src/Configs/container.php');
$server = \Focus\Server::init(\Focus\Container::instance()
->setContainer($basicContainer));
$server->registerExceptionHandler(function ($exception) {
echo "<pre>";
echo $exception;
echo "</pre>";
});
$server->setNotFoundRouter(new \Demo\Libraries\NotFoundRouter());
// 先注册者优先
$server->registerRouter(new \Focus\MVC\Router('Demo\Controllers', [
'/^article\/([0-9]+).html$/' => 'post/show?id=$1',
'/^category\/([0-9]+).html$/' => 'post/list?cat=$1',
'/^tag\/(.*?).html$/' => 'post/tag?tag=$1',
'/^about.html$/' => 'index/about',
'/^api\/blog\/related-(.*?).json$/' => 'api/relatedPosts?tags=$1',
'/^管宜尧$/' => 'index/admin',
'/^cache$/' => 'index/cache',
'/^rss.xml$/' => 'rss/show'
]));
$server->run();