<?php
namespace Misuzu;

define('MSZ_STARTUP', microtime(true));
define('MSZ_ROOT', __DIR__);

require_once __DIR__ . '/vendor/autoload.php';

\Dotenv\Dotenv::createImmutable(Misuzu::PATH_ROOT)->load();

if(!empty($_ENV['SENTRY_DSN']))
    \Sentry\init(['dsn' => $_ENV['SENTRY_DSN']]);

(function(\Whoops\RunInterface $whoops) {
    if(Misuzu::cli())
        $whoops->pushHandler(new Whoops\SentryPlainTextHandler);
    elseif(Misuzu::debug())
        $whoops->pushHandler(new \Whoops\Handler\PrettyPageHandler);
    else
        $whoops->pushHandler(new Whoops\SentryPageHandler);

    $whoops->register();
})(new \Whoops\Run);

$msz = new MisuzuContext(
    $_ENV['DATABASE_DSN'] ?? 'null:',
    $_ENV['DOMAIN_ROLES'] ?? 'localhost=main,redirect:/go'
);