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

52 lines
813 B
PHP
Raw Normal View History

2022-01-15 11:26:02 +01:00
<?php
/*
This is the main file to be included on every page.
It will act as a front controller of our application.
2022-01-16 17:12:04 +01:00
_____
/ \
| () () |
\ ^ /
|||||
|||||
Tread carefully
2022-01-15 11:26:02 +01:00
*/
2022-01-23 22:56:36 +01:00
// Disable type coercion
declare(strict_types=1);
2022-01-17 11:25:34 +01:00
// Autoloader
2022-01-15 11:26:02 +01:00
spl_autoload_register(function ($class_name) {
require __DIR__ . '/core/' . $class_name . '.php';
});
2022-01-17 11:25:34 +01:00
2022-01-30 22:11:38 +01:00
/* === App Setup === */
2022-01-27 23:17:43 +01:00
new ErrorHandler;
2022-01-24 08:38:51 +01:00
$config = (
new Config(__DIR__ . '/config.php')
)->config;
2022-01-27 23:17:43 +01:00
2022-01-21 21:32:21 +01:00
$database = new Database($config['database']);
$session = new Session;
2022-01-23 22:56:36 +01:00
$user = new User($session);
2022-01-21 21:32:21 +01:00
2022-01-30 22:11:38 +01:00
new AccessControl($user);
2022-01-21 21:32:21 +01:00
$app = new App(
$config,
$database,
2022-01-23 22:56:36 +01:00
$session,
$user
2022-01-21 21:32:21 +01:00
);
2022-01-23 22:56:36 +01:00
// We will use $app instead
2022-01-21 21:32:21 +01:00
unset(
$config,
$database,
2022-01-23 22:56:36 +01:00
$session,
$user
2022-01-21 21:32:21 +01:00
);
return $app;