2023-01-06 22:20:13 +00:00
|
|
|
<?php
|
|
|
|
namespace Hanyuu;
|
|
|
|
|
|
|
|
use Index\Environment;
|
2023-01-09 21:44:34 +00:00
|
|
|
use Index\Data\DbTools;
|
2023-10-20 21:38:13 +00:00
|
|
|
use Syokuhou\SharpConfig;
|
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');
|
2023-01-09 00:02:23 +00:00
|
|
|
define('HAU_DIR_TEMPLATES', HAU_ROOT . '/templates');
|
2023-01-06 22:20:13 +00:00
|
|
|
|
2023-10-18 10:40:21 +00:00
|
|
|
require_once HAU_ROOT . '/vendor/autoload.php';
|
2023-01-06 22:20:13 +00:00
|
|
|
|
|
|
|
Environment::setDebug(HAU_DEBUG);
|
|
|
|
mb_internal_encoding('utf-8');
|
|
|
|
date_default_timezone_set('utc');
|
|
|
|
|
2023-12-15 02:24:24 +00:00
|
|
|
$cfg = SharpConfig::fromFile(HAU_ROOT . '/hanyuu.cfg');
|
|
|
|
|
|
|
|
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
|
|
|
|
2023-10-20 21:38:13 +00:00
|
|
|
$dbc = DbTools::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);
|