Initial
This commit is contained in:
@@ -0,0 +1,43 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* Einziger Einstiegspunkt des Backends.
|
||||
*
|
||||
* nginx reicht ausschliesslich /api/ hierher weiter; alles andere ist die
|
||||
* statisch gebaute Oberflaeche und wird direkt von nginx ausgeliefert.
|
||||
*/
|
||||
|
||||
use Ekdos\Bootstrap\Container;
|
||||
use Ekdos\Bootstrap\Routes;
|
||||
use Ekdos\Http\Middleware\ErrorHandler;
|
||||
use Ekdos\Http\Middleware\SessionMiddleware;
|
||||
use Ekdos\Support\Config;
|
||||
use Slim\Factory\AppFactory;
|
||||
|
||||
require __DIR__ . '/../vendor/autoload.php';
|
||||
|
||||
$projectRoot = dirname(__DIR__);
|
||||
$container = Container::build($projectRoot);
|
||||
|
||||
/** @var Config $config */
|
||||
$config = $container->get(Config::class);
|
||||
|
||||
// Ausnahmen gehen in den Fehlerkanal von php-fpm, niemals in die Antwort.
|
||||
ini_set('display_errors', '0');
|
||||
ini_set('log_errors', '1');
|
||||
|
||||
AppFactory::setContainer($container);
|
||||
$app = AppFactory::create();
|
||||
|
||||
Routes::register($app);
|
||||
|
||||
// Reihenfolge: zuletzt hinzugefuegt laeuft zuerst.
|
||||
// ErrorHandler -> Session -> Routing -> Body-Parsing -> Route.
|
||||
$app->addBodyParsingMiddleware();
|
||||
$app->addRoutingMiddleware();
|
||||
$app->add($container->get(SessionMiddleware::class));
|
||||
$app->add(new ErrorHandler($config->bool('APP_DEBUG', false)));
|
||||
|
||||
$app->run();
|
||||
Reference in New Issue
Block a user