-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbootstrap.php
More file actions
39 lines (30 loc) · 1.04 KB
/
bootstrap.php
File metadata and controls
39 lines (30 loc) · 1.04 KB
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
<?php
declare(strict_types=1);
use Framework\Events\LifecycleEvents\ExceptionOccurred;
require_once __DIR__ . '/vendor/autoload.php';
session_start();
$dotenv = Dotenv\Dotenv::createImmutable(__DIR__);
$dotenv->load();
if (class_exists(Whoops\Run::class) && env('APP_DEBUG') === 'true') {
$whoops = new Whoops\Run();
$handler = new Whoops\Handler\PrettyPageHandler();
$handler->setEditor(env('WHOOPS_IDE'));
if (Whoops\Util\Misc::isCommandLine()) {
$handler = new Whoops\Handler\PlainTextHandler();
} elseif (Whoops\Util\Misc::isAjaxRequest()) {
$handler = new Whoops\Handler\JsonResponseHandler();
}
$whoops->pushHandler($handler);
$whoops->pushHandler(
new Whoops\Handler\CallbackHandler(
static function (Throwable $throwable): void {
ExceptionOccurred::occur($throwable);
}
)
);
$whoops->register();
} else {
set_exception_handler(static function (Throwable $throwable): void {
ExceptionOccurred::occur($throwable);
});
}