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

54 lines
1.1 KiB
PHP
Raw Normal View History

2022-01-15 10:26:02 +00:00
<?php
2022-03-02 06:15:12 +00:00
/**
* This is the main file to be included on every page.
* It will act as a front controller of our application.
* _____
* / \
* | () () |
* \ ^ /
* |||||
* |||||
*
* Tread carefully
*/
2022-04-14 20:59:42 +00:00
$php_version = '8';
if (version_compare(PHP_VERSION, $php_version, '<'))
{
echo 'This app requires a minimum of PHP ' . $php_version . ' current being: ' . PHP_VERSION . "\n";
die();
}
unset($php_version);
2022-03-02 06:15:12 +00:00
// PSR-4 like autoloader
spl_autoload_register(
2022-04-14 20:59:42 +00:00
function ($class_name) {
$path = __DIR__ . '/lib/' . str_replace('\\', '/', $class_name) . '.php';
2022-03-02 06:15:12 +00:00
require $path;
}
);
2022-01-17 10:25:34 +00:00
2022-03-02 06:15:12 +00:00
use App\Core\ {
ErrorHandler,
Config,
Database,
Session,
User,
App,
AccessControl
};
2022-01-30 21:11:38 +00:00
2022-03-02 06:15:12 +00:00
new ErrorHandler();
2022-01-27 22:17:43 +00:00
2022-04-14 20:59:42 +00:00
$config = (new Config(__DIR__ . '/config.php'))->config;
2022-01-21 20:32:21 +00:00
$database = new Database($config['database']);
2022-04-14 20:59:42 +00:00
$session = new Session();
$user = new User($session, $database);
$app = new App(__DIR__, $config, $database, $session, $user);
2022-01-21 20:32:21 +00:00
2022-03-02 06:15:12 +00:00
// we will use $app instead
unset($config, $database, $session, $user);
2022-03-13 19:54:34 +00:00
new AccessControl($app);
2022-01-21 20:32:21 +00:00
return $app;