first commit

This commit is contained in:
julien
2026-02-22 14:36:40 +01:00
commit ebcd2f007f
11 changed files with 319 additions and 0 deletions

58
public/index.php Normal file
View File

@@ -0,0 +1,58 @@
<?php
declare(strict_types=1);
use Slim\Factory\AppFactory;
use Slim\Views\Twig;
use Slim\Views\TwigMiddleware;
use Illuminate\Database\Capsule\Manager as Capsule;
require __DIR__ . '/../vendor/autoload.php';
/* -------------------------------------------------
Instanciation de lapplication Slim
------------------------------------------------- */
$app = AppFactory::create();
/* -------------------------------------------------
Middleware derreur (affiche les exceptions)
------------------------------------------------- */
$app->addErrorMiddleware(true, true, true);
/* -------------------------------------------------
Twig (templates)
------------------------------------------------- */
$twig = Twig::create(__DIR__ . '/../views', ['cache' => false]);
$app->add(TwigMiddleware::create($app, $twig));
/* -------------------------------------------------
Vérification / création du fichier SQLite
------------------------------------------------- */
$dbFile = __DIR__ . '/../database/blog.sqlite';
if (!file_exists($dbFile)) {
// crée un fichier vide et lui donne les permissions décriture
touch($dbFile);
chmod($dbFile, 0664);
}
/* -------------------------------------------------
Eloquent (connexion SQLite)
------------------------------------------------- */
$capsule = new Capsule;
$capsule->addConnection([
'driver' => 'sqlite',
// le chemin relatif fonctionne ; SQLite créera le fichier si besoin
'database' => $dbFile,
'prefix' => '',
]);
$capsule->setAsGlobal();
$capsule->bootEloquent();
/* -------------------------------------------------
Chargement des routes
------------------------------------------------- */
(require __DIR__ . '/../src/routes.php')($app);
/* -------------------------------------------------
Démarrage de lapplication
------------------------------------------------- */
$app->run();