<?php

use Slim\Factory\AppFactory;
use Dotenv\Dotenv;

require __DIR__ . '/../vendor/autoload.php';

// Load .env file
$dotenv = Dotenv::createImmutable(__DIR__ . '/../');
$dotenv->load();

// Create Slim app
$app = AppFactory::create();
$app->setBasePath('/school-api/public');

// Add routing middleware
$app->addRoutingMiddleware();

// Add error middleware — set false/false/false for production
$app->addErrorMiddleware(true, true, true);

// Load all routes
(require __DIR__ . '/../src/Routes/result.php')($app);
(require __DIR__ . '/../src/Routes/attendance.php')($app);
(require __DIR__ . '/../src/Routes/fee.php')($app);

// Run the app
$app->run();
