generated from Lemon-Framework/app
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinit.php
56 lines (41 loc) · 1.4 KB
/
init.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
<?php
declare(strict_types=1);
include __DIR__.'/vendor/autoload.php';
use App\Contracts\Services as ContractsServices;
use App\Contracts\WebhookManager as ContractsWebhookManager;
use App\Services;
use App\WebhookManager;
use Lemon\Http\Middlewares\Cors;
use Lemon\Kernel\Application;
use Lemon\Protection\Middlwares\Csrf;
$application = new Application(__DIR__);
// --- Loading default Lemon services ---
$application->loadServices();
// --- Loading Zests for services ---
$application->loadZests();
// --- Loading Error/Exception handlers ---
$application->loadHandler();
$application->get('config')->load();
/** @var \Lemon\Routing\Router $router */
$router = $application->get('routing');
$router->file('routes.web')
->middleware(Csrf::class)
;
$router->file('routes.api')
->prefix('api')
->middleware(Cors::class)
;
$application->add(Services::class);
$application->alias(ContractsServices::class, Services::class);
$application->get('templating.env')->macro('capitalize', 'ucfirst');
$application->get('templating.env')->macro('toStatusClass', function (int $status) {
return match ($status) {
0 => 'offline',
1 => 'online',
2 => 'maintenance',
default => throw new Exception('Status '.$status.' doesnt have class')
};
});
$application->add(WebhookManager::class);
$application->alias(ContractsWebhookManager::class, WebhookManager::class);
return $application;