portfolio/public/index.php

45 lines
1.1 KiB
PHP
Raw Normal View History

2022-06-21 10:33:35 +00:00
<?php
use App\App;
use App\Middlewares\TwigLocalizationMiddleware;
2022-06-21 10:33:35 +00:00
use App\Util\ContainerBuilder;
use App\Utils\DotEnv;
use Slim\Factory\AppFactory;
use Slim\Views\Twig;
use Slim\Views\TwigMiddleware;
use DI\Container;
use App\Middlewares\LocalizationMiddleware;
use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\ServerRequestInterface;
use Psr\Http\Server\RequestHandlerInterface;
2022-06-21 10:33:35 +00:00
use function App\addRoutes;
require '../vendor/autoload.php';
error_reporting(E_ALL);
ini_set('display_errors', 1);
date_default_timezone_set('Europe/Paris');
App::setBasePath(dirname(__DIR__));
$container = ContainerBuilder::direct();
$app = AppFactory::createFromContainer($container);
$app->addRoutingMiddleware();
$errorMiddleware = $app->addErrorMiddleware(true, true, true);
// we place the definition BEFORE the localization middleware to get the locale attribute
$app->add(new TwigLocalizationMiddleware($container));
$app->add($container->get(LocalizationMiddleware::class));
$app->add(TwigMiddleware::create($app, $container->get(Twig::class)));
2022-06-21 10:33:35 +00:00
require '../src/routes.php';
addRoutes($app);
$app->run();