pour prod
This commit is contained in:
26
page_bootstrap.php
Normal file
26
page_bootstrap.php
Normal file
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
require_once __DIR__ . '/app/autoload.php';
|
||||
|
||||
use App\Controllers\PageController;
|
||||
|
||||
function runPage(string $method): void
|
||||
{
|
||||
try {
|
||||
$pdo = require __DIR__ . '/app/bootstrap.php';
|
||||
$controller = new PageController($pdo);
|
||||
if (!method_exists($controller, $method)) {
|
||||
throw new RuntimeException('Page inconnue.');
|
||||
}
|
||||
$controller->{$method}();
|
||||
} catch (Throwable $e) {
|
||||
http_response_code(500);
|
||||
$message = htmlspecialchars($e->getMessage(), ENT_QUOTES, 'UTF-8');
|
||||
echo '<!doctype html><html lang="fr"><meta charset="utf-8"><title>Erreur PTA</title>';
|
||||
echo '<body style="font-family:Arial,sans-serif;padding:32px;max-width:900px;margin:auto">';
|
||||
echo '<h1>Impossible de démarrer PTA</h1><p>' . $message . '</p>';
|
||||
echo '<p>Vérifiez <code>config.php</code> et le schéma de la base de données.</p></body></html>';
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user