38 lines
1.2 KiB
PHP
38 lines
1.2 KiB
PHP
<?php
|
|
namespace Awaki;
|
|
|
|
use Index\Data\DbTools;
|
|
use Syokuhou\SharpConfig;
|
|
|
|
define('AWK_STARTUP', microtime(true));
|
|
define('AWK_ROOT', __DIR__);
|
|
define('AWK_DEBUG', is_file(AWK_ROOT . '/.debug'));
|
|
define('AWK_DIR_SRC', AWK_ROOT . '/src');
|
|
define('AWK_DIR_PUB', AWK_ROOT . '/public');
|
|
define('AWK_DIR_DBM', AWK_ROOT . '/database');
|
|
|
|
require_once AWK_ROOT . '/vendor/autoload.php';
|
|
|
|
error_reporting(AWK_DEBUG ? -1 : 0);
|
|
mb_internal_encoding('UTF-8');
|
|
date_default_timezone_set('GMT');
|
|
|
|
$config = SharpConfig::fromFile(AWK_ROOT . '/awaki.cfg');
|
|
|
|
if($config->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);
|
|
});
|
|
})($config->scopeTo('sentry'));
|
|
|
|
$db = DbTools::create($config->getString('database:dsn', 'null:'));
|
|
$db->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\';');
|
|
|
|
$awk = new AwakiContext($db, $config);
|