-
-
Notifications
You must be signed in to change notification settings - Fork 5
/
index.php
58 lines (48 loc) · 1.9 KB
/
index.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
<?php
/**
* @author Pierre-Henry Soria <[email protected]>
* @copyright (c) 2018-2020, Pierre-Henry Soria. All Rights Reserved.
* @license GNU General Public License; <https://www.gnu.org/licenses/gpl-3.0.en.html>
*/
declare(strict_types=1);
namespace Lifyzer;
use Dotenv\Dotenv;
use Lifyzer\Server\Core\Container\Container;
use Lifyzer\Server\Core\Container\Provider\Database as DatabaseContainer;
use Lifyzer\Server\Core\Container\Provider\HttpRequest as HttpRequestContainer;
use Lifyzer\Server\Core\Container\Provider\Monolog as MonologContainer;
use Lifyzer\Server\Core\Container\Provider\SwiftMailer as SwiftMailerContainer;
use Lifyzer\Server\Core\Container\Provider\Twig as TwigContainer;
use Lifyzer\Server\Core\Debug;
use Lifyzer\Server\Core\Uri\Router;
use Whoops\Handler\PrettyPageHandler;
use Whoops\Run as WhoopsRun;
require __DIR__ . '/Server/vendor/autoload.php';
$whoops = new WhoopsRun;
$whoops->pushHandler(new PrettyPageHandler);
$whoops->register();
$requiredEnvFields = [
'SITE_URL',
'SITE_NAME',
'ADMIN_EMAIL',
'DB_HOST',
'DB_USER',
'DB_PWD',
'DB_NAME',
'LOGGING_CHANNEL'
];
$env = Dotenv::createImmutable(__DIR__ . '/Server/config');
$env->load();
$env->required($requiredEnvFields)->notEmpty();
define('SITE_NAME', $_ENV['SITE_NAME']);
define('SITE_URL', $_ENV['SITE_URL']);
Debug::initializeMode();
$container = new Container();
$container->register(TwigContainer::class, new TwigContainer());
$container->register(DatabaseContainer::class, new DatabaseContainer());
$container->register(HttpRequestContainer::class, new HttpRequestContainer());
$container->register(SwiftMailerContainer::class, new SwiftMailerContainer());
$container->register(MonologContainer::class, new MonologContainer($_ENV['LOGGING_CHANNEL']));
$dispatcher = require __DIR__ . '/Server/config/routes.php';
$router = new Router($dispatcher, $container);
$router->dispatch();