34 lines
733 B
PHP
34 lines
733 B
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
require __DIR__ . '/../vendor/autoload.php';
|
|
|
|
use Slim\Factory\AppFactory;
|
|
use Slim\Views\TwigMiddleware;
|
|
|
|
// Charger et créer les services centralisés
|
|
$services = App\Factories\ServiceFactory::createServices();
|
|
|
|
/** @var \Slim\Views\Twig $twig */
|
|
$twig = $services['view'];
|
|
|
|
// Slim app
|
|
$app = AppFactory::create();
|
|
|
|
// Middlewares essentiels
|
|
$app->addBodyParsingMiddleware();
|
|
$app->add(TwigMiddleware::create($app, $twig));
|
|
|
|
// Charger les routes
|
|
$routesPath = __DIR__ . '/../src/Routes/web.php';
|
|
if (file_exists($routesPath)) {
|
|
/** @var callable $routes */
|
|
$routes = require $routesPath;
|
|
$routes($app);
|
|
}
|
|
|
|
$errorMiddleware = $app->addErrorMiddleware(true, true, true);
|
|
|
|
$app->run();
|