From 2bf3448d185ac914fecba8129fa43cfb4f2d7b4b Mon Sep 17 00:00:00 2001 From: Bernd Bestel Date: Sun, 15 Apr 2018 14:51:31 +0200 Subject: [PATCH] Separate app bootstrapping and routes --- app.php | 47 +++++++++++++++++++++++++++++++++++++ public/index.php | 2 +- bootstrap.php => routes.php | 44 ---------------------------------- 3 files changed, 48 insertions(+), 45 deletions(-) create mode 100644 app.php rename bootstrap.php => routes.php (78%) diff --git a/app.php b/app.php new file mode 100644 index 00000000..bcfcae3a --- /dev/null +++ b/app.php @@ -0,0 +1,47 @@ + [ + 'displayErrorDetails' => true, + 'determineRouteBeforeAppMiddleware' => true + ], + 'view' => function($container) + { + return new \Slim\Views\Blade(__DIR__ . '/views', __DIR__ . '/data/viewcache'); + } + ]); + + $app = new \Slim\App($appContainer); +} +else +{ + $app = new \Slim\App(); + $app->add(\pavlakis\cli\CliRequest::class); +} + +// Add session handling if this is not a demo installation +$applicationService = new ApplicationService(); +if (!$applicationService->IsDemoInstallation()) +{ + $app->add(SessionAuthMiddleware::class); +} + +require_once __DIR__ . '/routes.php'; + +$app->run(); diff --git a/public/index.php b/public/index.php index bf457d54..64e013e1 100644 --- a/public/index.php +++ b/public/index.php @@ -1,3 +1,3 @@ [ - 'displayErrorDetails' => true, - 'determineRouteBeforeAppMiddleware' => true - ], - 'view' => function($container) - { - return new \Slim\Views\Blade(__DIR__ . '/views', __DIR__ . '/data/viewcache'); - } - ]); - - $app = new \Slim\App($appContainer); -} -else -{ - $app = new \Slim\App(); - $app->add(\pavlakis\cli\CliRequest::class); -} - -// Add session handling if this is not a demo installation -$applicationService = new ApplicationService(); -if (!$applicationService->IsDemoInstallation()) -{ - $app->add(SessionAuthMiddleware::class); -} - // Base route $app->get('/', 'Grocy\Controllers\LoginController:Root')->setName('root'); @@ -110,5 +68,3 @@ $app->group('/cli', function() { $this->get('/recreatedemo', 'Grocy\Controllers\CliController:RecreateDemo'); })->add(CliMiddleware::class); - -$app->run();