forked from flarum/flarum
-
Notifications
You must be signed in to change notification settings - Fork 0
/
admin.php
46 lines (36 loc) · 1.13 KB
/
admin.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
<?php
/*
* This file is part of Flarum.
*
* (c) Toby Zerner <[email protected]>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
use Flarum\Core;
use Flarum\Forum\Middleware\HandleErrors;
use Franzl\Middleware\Whoops\Middleware as WhoopsMiddleware;
use Zend\Diactoros\Server;
use Zend\Stratigility\MiddlewarePipe;
$app = require __DIR__.'/flarum/bootstrap.php';
$app->register('Flarum\Admin\AdminServiceProvider');
$admin = new MiddlewarePipe();
$admin->pipe($app->make('Flarum\Api\Middleware\ReadJsonParameters'));
$admin->pipe($app->make('Flarum\Admin\Middleware\LoginWithCookieAndCheckAdmin'));
$adminPath = parse_url(Core::url('admin'), PHP_URL_PATH);
$router = $app->make('Flarum\Http\RouterMiddleware', ['routes' => $app->make('flarum.admin.routes')]);
$admin->pipe($adminPath, $router);
if (Core::inDebugMode()) {
$admin->pipe(new WhoopsMiddleware());
} else {
$admin->pipe(new HandleErrors(base_path('error')));
}
$server = Server::createServer(
$admin,
$_SERVER,
$_GET,
$_POST,
$_COOKIE,
$_FILES
);
$server->listen();