50 lines
802 B
PHP
50 lines
802 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
|
|
*/
|
|
|
|
// Disable type coercion
|
|
declare(strict_types=1);
|
|
|
|
// Autoloader
|
|
spl_autoload_register(function ($class_name) {
|
|
require __DIR__ . '/core/' . $class_name . '.php';
|
|
});
|
|
|
|
// Error and exception handling
|
|
new ErrorHandler;
|
|
|
|
// Setup
|
|
$config = (
|
|
new Config(__DIR__ . '/config.php')
|
|
)->config;
|
|
|
|
$database = new Database($config['database']);
|
|
$session = new Session;
|
|
$user = new User($session);
|
|
|
|
$app = new App(
|
|
$config,
|
|
$database,
|
|
$session,
|
|
$user
|
|
);
|
|
|
|
// We will use $app instead
|
|
unset(
|
|
$config,
|
|
$database,
|
|
$session,
|
|
$user
|
|
);
|
|
|
|
return $app; |