From 57af56cefa3e9e35bbf94dc5db3d73f7ded39024 Mon Sep 17 00:00:00 2001 From: Josh Richards Date: Sun, 15 Feb 2026 13:52:17 -0500 Subject: [PATCH] refactor(app): add bootstrap config constants Signed-off-by: Josh Richards --- php/public/index.php | 64 +++++++++++++++++++++++++++++++------------- 1 file changed, 45 insertions(+), 19 deletions(-) diff --git a/php/public/index.php b/php/public/index.php index 16de2bab..5b555382 100644 --- a/php/public/index.php +++ b/php/public/index.php @@ -1,14 +1,12 @@ get(\AIO\Data\DataConst::class); ini_set('session.save_path', $dataConst->GetSessionDirectory()); -// Auto logout on browser close -ini_set('session.cookie_lifetime', '0'); - -# Keep session for 24h max -ini_set('session.gc_maxlifetime', '86400'); - -// Create app -AppFactory::setContainer($container); +//------------------------------------------------- +// Application Creation and Core Middleware +//------------------------------------------------- $app = AppFactory::create(); $responseFactory = $app->getResponseFactory(); @@ -45,8 +63,9 @@ $container->set(Guard::class, function () use ($responseFactory): Guard { session_start(); $app->add(Guard::class); -// Create Twig -$twig = Twig::create(__DIR__ . '/../templates/', ['cache' => false]); +$twig = Twig::create(__DIR__ . '/../templates/', + [ 'cache' => AIO_TWIG_CACHE_PATH ] +); $app->add(TwigMiddleware::create($app, $twig)); $twig->addExtension(new \AIO\Twig\CsrfExtension($container->get(Guard::class))); @@ -199,6 +218,13 @@ $app->get('/', function (Request $request, Response $response, array $args) use } }); -$errorMiddleware = $app->addErrorMiddleware(false, true, true); +//------------------------------------------------- +// Error Middleware +//------------------------------------------------- + +// TODO: Figure out why the default plain text renderer is being used by logging +// TODO: Change logging to not generate stack traces for 404s +// TODO: Change logging to log the path +$errorMiddleware = $app->addErrorMiddleware(AIO_DISPLAY_ERRORS, true, true); $app->run();