Dragon-Knight/server/app/app.php

32 lines
648 B
PHP
Raw Normal View History

<?php
/*
The app container exists to be a dependency container for the game.
*/
class App
{
public static Database $db;
public static Request $req;
public function __construct(string $dbPath)
{
self::$req = new Request(); // the current request
self::$db = new Database($dbPath); // the database
}
2024-07-11 18:17:51 -05:00
public function route(string $uri, array $routes)
{
// check if the module exists
if (isset($routes[$module])) {
// if the module exists, call the module's handle method
$routes[$module]($this);
} else {
// if the module does not exist, render a 404 page
$this->render('404', [
'title' => '404',
]);
}
}
}