42 lines
1.4 KiB
PHP
42 lines
1.4 KiB
PHP
<?php
|
|
namespace Hanyuu;
|
|
|
|
use Index\Environment;
|
|
use Index\Data\DbTools;
|
|
use Syokuhou\SharpConfig;
|
|
|
|
define('HAU_STARTUP', microtime(true));
|
|
define('HAU_ROOT', __DIR__);
|
|
define('HAU_CLI', PHP_SAPI === 'cli');
|
|
define('HAU_DEBUG', is_file(HAU_ROOT . '/.debug'));
|
|
define('HAU_DIR_ASSETS', HAU_ROOT . '/assets');
|
|
define('HAU_DIR_PUBLIC', HAU_ROOT . '/public');
|
|
define('HAU_DIR_SOURCE', HAU_ROOT . '/src');
|
|
define('HAU_DIR_MIGRATIONS', HAU_ROOT . '/database');
|
|
define('HAU_DIR_TEMPLATES', HAU_ROOT . '/templates');
|
|
|
|
require_once HAU_ROOT . '/vendor/autoload.php';
|
|
|
|
Environment::setDebug(HAU_DEBUG);
|
|
mb_internal_encoding('utf-8');
|
|
date_default_timezone_set('utc');
|
|
|
|
$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),
|
|
]);
|
|
|
|
set_exception_handler(function(\Throwable $ex) {
|
|
\Sentry\captureException($ex);
|
|
});
|
|
})($cfg->scopeTo('sentry'));
|
|
|
|
$dbc = DbTools::create($cfg->getString('database:dsn', 'null'));
|
|
$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);
|