Exemplo n.º 1
0
    return true;
}, E_ERROR);
// Set global exception handler
set_exception_handler(function (Exception $exception) {
    if ($exception instanceof ApplicationException) {
        $message = $exception->getMessage();
        $http_code = $exception->getHttpCode();
    } else {
        $message = $exception->getMessage();
        $http_code = HttpStatusCodes::HTTP_INTERNAL_SERVER_ERROR;
    }
    error_log("Exception: " . $exception->getMessage());
    error_log("Stacktrace: " . $exception->getTraceAsString());
    http_response_code($http_code);
    $response_data = array("message" => $message, "code" => $http_code);
    JsonResponse::ifInstance()->call("write", $response_data)->otherwise(Consumer::call([TinyView::class, "show"], "error.tmpl", $response_data));
});
// Scan autorun directory for executable scripts
foreach (scandir(AUTORUN_SCRIPTS_PATH) as $file) {
    if ($file == "." || $file == "..") {
        continue;
    }
    require_once AUTORUN_SCRIPTS_PATH . $file;
}
function static_class_init($class_name)
{
    if (class_exists($class_name) && method_exists($class_name, STATIC_CLASS_INIT_METHOD)) {
        $ref = new ReflectionMethod($class_name, STATIC_CLASS_INIT_METHOD);
        if ($ref->isStatic()) {
            Injector::run($ref);
        }