hanyuu/hanyuu.php

42 lines
1.4 KiB
PHP
Raw Permalink Normal View History

2023-01-06 22:20:13 +00:00
<?php
namespace Hanyuu;
2024-11-13 23:58:43 +00:00
use Index\Db\DbBackends;
use Index\Config\Fs\FsConfig;
2023-01-06 22:20:13 +00:00
define('HAU_STARTUP', microtime(true));
define('HAU_ROOT', __DIR__);
define('HAU_CLI', PHP_SAPI === 'cli');
define('HAU_DEBUG', is_file(HAU_ROOT . '/.debug'));
2024-06-11 22:50:55 +00:00
define('HAU_DIR_ASSETS', HAU_ROOT . '/assets');
2023-01-06 22:20:13 +00:00
define('HAU_DIR_PUBLIC', HAU_ROOT . '/public');
define('HAU_DIR_SOURCE', HAU_ROOT . '/src');
2023-01-07 04:36:22 +00:00
define('HAU_DIR_MIGRATIONS', HAU_ROOT . '/database');
define('HAU_DIR_TEMPLATES', HAU_ROOT . '/templates');
2023-01-06 22:20:13 +00:00
require_once HAU_ROOT . '/vendor/autoload.php';
2023-01-06 22:20:13 +00:00
error_reporting(HAU_DEBUG ? -1 : 0);
mb_internal_encoding('UTF-8');
date_default_timezone_set('GMT');
2023-01-06 22:20:13 +00:00
2024-11-13 23:58:43 +00:00
$cfg = FsConfig::fromFile(HAU_ROOT . '/hanyuu.cfg');
2023-12-15 02:24:24 +00:00
if($cfg->hasValues('sentry:dsn'))
(function($cfg) {
\Sentry\init([
'dsn' => $cfg->getString('dsn'),
'traces_sample_rate' => $cfg->getFloat('tracesRate', 0.2),
'profiles_sample_rate' => $cfg->getFloat('profilesRate', 0.2),
]);
2023-01-06 22:20:13 +00:00
2023-12-15 02:38:40 +00:00
set_exception_handler(function(\Throwable $ex) {
\Sentry\captureException($ex);
});
})($cfg->scopeTo('sentry'));
2023-01-06 22:20:13 +00:00
2024-11-13 23:58:43 +00:00
$dbc = DbBackends::create($cfg->getString('database:dsn', 'null'));
2023-01-09 21:44:34 +00:00
$dbc->execute('SET SESSION time_zone = \'+00:00\', sql_mode = \'STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION\';');
$hau = new HanyuuContext($cfg, $dbc);