flarum/admin.php

38 lines
1017 B
PHP
Raw Normal View History

<?php
2015-08-02 08:12:13 +00:00
use Flarum\Core;
use Zend\Diactoros\Server;
use Zend\Stratigility\MiddlewarePipe;
// Instantiate the application, register providers etc.
2015-08-12 07:47:13 +00:00
$app = require __DIR__.'/flarum/bootstrap.php';
// Set up everything we need for the frontend
$app->register('Flarum\Admin\AdminServiceProvider');
2015-08-02 08:12:13 +00:00
// Build a middleware pipeline for Flarum
$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);
$admin->pipe($adminPath, $app->make('Flarum\Http\RouterMiddleware', ['routes' => $app->make('flarum.admin.routes')]));
2015-08-02 08:12:13 +00:00
// Handle errors
if (Core::inDebugMode()) {
$admin->pipe(new \Franzl\Middleware\Whoops\Middleware());
} else {
$admin->pipe(new \Flarum\Forum\Middleware\HandleErrors(base_path('error')));
}
$server = Server::createServer(
$admin,
$_SERVER,
$_GET,
$_POST,
$_COOKIE,
$_FILES
);
$server->listen();