aboutsummaryrefslogtreecommitdiff
path: root/index.php
blob: 49974f7cb246d98f089afb26ed55fa2d5899ad0c (plain)
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
<?php

session_start();


require('./vendor/autoload.php');

try {
    Wcms\Logger::init('w_error.log', 2);
} catch (RuntimeException $e) {
    die('Unable to init logs: ' . $e->getMessage());
}

$app = new Wcms\Application();
$app->wakeup();

if (class_exists('Whoops\Run') && !empty(Wcms\Config::debug())) {
    $whoops = new \Whoops\Run();
    $handler = new \Whoops\Handler\PrettyPageHandler();
    $handler->setEditor(\Wcms\Config::debug());
    $whoops->pushHandler($handler);
    $whoops->register();
}

if (isreportingerrors()) {
    Sentry\init([
        'dsn' => Wcms\Config::sentrydsn(),
        'release' => getversion(),
        'project_root' => 'app',
    ]);
    Sentry\configureScope(function ($scope) {
        $scope->setUser([
            'id' => Wcms\Config::url(),
            'username' => Wcms\Config::basepath(),
        ]);
    });
}

try {
    $matchoper = new Wcms\Routes();
    $matchoper->match();
} catch (Throwable $e) {
    if (isreportingerrors()) {
        Sentry\captureException($e);
    }
    Wcms\Logger::errorex($e, true);
    http_response_code(500);
    if (isset($whoops)) {
        $whoops->handleException($e);
    }
    echo '<h1>⚠ Whoops ! There is a little problem : </h1>', $e->getMessage(), "\n";
}