flarum/admin.php

47 lines
1.1 KiB
PHP
Raw Normal View History

<?php
2015-08-26 07:43:18 +00:00
/*
* This file is part of Flarum.
*
* (c) Toby Zerner <toby.zerner@gmail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
2015-08-02 08:12:13 +00:00
use Flarum\Core;
2015-08-26 07:43:18 +00:00
use Flarum\Forum\Middleware\HandleErrors;
use Franzl\Middleware\Whoops\Middleware as WhoopsMiddleware;
use Zend\Diactoros\Server;
use Zend\Stratigility\MiddlewarePipe;
2015-08-12 07:47:13 +00:00
$app = require __DIR__.'/flarum/bootstrap.php';
$app->register('Flarum\Admin\AdminServiceProvider');
$admin = new MiddlewarePipe();
2015-08-02 08:12:13 +00:00
$admin->pipe($app->make('Flarum\Api\Middleware\ReadJsonParameters'));
$admin->pipe($app->make('Flarum\Admin\Middleware\LoginWithCookieAndCheckAdmin'));
2015-08-14 03:23:42 +00:00
$adminPath = parse_url(Core::config('admin_url'), PHP_URL_PATH);
2015-08-26 07:43:18 +00:00
$router = $app->make('Flarum\Http\RouterMiddleware', ['routes' => $app->make('flarum.admin.routes')]);
$admin->pipe($adminPath, $router);
2015-08-02 08:12:13 +00:00
if (Core::inDebugMode()) {
2015-08-26 07:43:18 +00:00
$admin->pipe(new WhoopsMiddleware());
2015-08-02 08:12:13 +00:00
} else {
2015-08-26 07:43:18 +00:00
$admin->pipe(new HandleErrors(base_path('error')));
2015-08-02 08:12:13 +00:00
}
$server = Server::createServer(
2015-08-26 07:43:18 +00:00
$admin,
$_SERVER,
$_GET,
$_POST,
$_COOKIE,
$_FILES
);
$server->listen();