This repository has been archived on 2023-01-06. You can view files and clone it, but cannot push or open issues or pull requests.
web/app/inc.php
2022-04-13 19:22:21 +00:00

50 lines
891 B
PHP

<?php
/**
* This is the main file to be included on every page.
* It will act as a front controller of our application.
* _____
* / \
* | () () |
* \ ^ /
* |||||
* |||||
*
* Tread carefully
*/
// PSR-4 like autoloader
spl_autoload_register(
function ($className) {
$path = __DIR__ . '/lib/' . str_replace('\\', '/', $className) . '.php';
require $path;
}
);
use App\Core\ {
ErrorHandler,
Config,
Database,
Session,
User,
App,
AccessControl
};
new ErrorHandler();
$config = (new Config(__DIR__ . '/config.php'))->config;
$database = new Database($config['database']);
$session = new Session();
$user = new User($session, $database);
$app = new App(__DIR__, $config, $database, $session, $user);
// we will use $app instead
unset($config, $database, $session, $user);
new AccessControl($app);
return $app;