39 lines
1.2 KiB
PHP
39 lines
1.2 KiB
PHP
<?php
|
|
use Psr\Http\Message\ResponseInterface as Response;
|
|
use Psr\Http\Message\ServerRequestInterface as Request;
|
|
use Slim\Factory\AppFactory;
|
|
use Slim\Views\Twig;
|
|
use Slim\Views\TwigMiddleware;
|
|
|
|
require __DIR__ . '/../vendor/autoload.php';
|
|
|
|
$app = AppFactory::create();
|
|
|
|
/**
|
|
* The routing middleware should be added earlier than the ErrorMiddleware
|
|
* Otherwise exceptions thrown from it will not be handled by the middleware
|
|
*/
|
|
$app->addRoutingMiddleware();
|
|
|
|
/**
|
|
* Add Error Middleware
|
|
*
|
|
* @param bool $displayErrorDetails -> Should be set to false in production
|
|
* @param bool $logErrors -> Parameter is passed to the default ErrorHandler
|
|
* @param bool $logErrorDetails -> Display error details in error log
|
|
* @param LoggerInterface|null $logger -> Optional PSR-3 Logger
|
|
*
|
|
* Note: This middleware should be added last. It will not handle any exceptions/errors
|
|
* for middleware added after it.
|
|
*/
|
|
$errorMiddleware = $app->addErrorMiddleware(true, true, true);
|
|
|
|
// Create Twig
|
|
$twig = Twig::create(__DIR__ . '/../views', ['cache' => false]);
|
|
|
|
// Add Twig-View Middleware
|
|
$app->add(TwigMiddleware::create($app, $twig));
|
|
|
|
// Instantiate routes
|
|
require_once __DIR__ . '/routes.php';
|