awaki/awaki.php

44 lines
1.2 KiB
PHP
Raw Normal View History

2022-07-03 23:14:15 +00:00
<?php
namespace Awaki;
use Index\Environment;
use Index\Data\ConnectionFailedException;
use Index\Data\DbTools;
2023-10-21 14:21:02 +00:00
use Syokuhou\SharpConfig;
2022-07-03 23:14:15 +00:00
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_CFG', AWK_ROOT . '/config');
2023-01-07 21:16:49 +00:00
define('AWK_DIR_DBM', AWK_ROOT . '/database');
2022-07-03 23:14:15 +00:00
2023-10-21 14:16:40 +00:00
require_once AWK_ROOT . '/vendor/autoload.php';
2022-07-03 23:14:15 +00:00
Environment::setDebug(AWK_DEBUG);
2023-10-21 14:21:02 +00:00
$config = SharpConfig::fromFile(AWK_DIR_CFG . '/config.cfg');
2022-07-03 23:14:15 +00:00
2023-12-15 01:00:31 +00:00
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'));
2022-07-03 23:14:15 +00:00
try {
2023-10-21 14:21:02 +00:00
$db = DbTools::create($config->getString('dsn'));
2022-07-03 23:14:15 +00:00
} catch(ConnectionFailedException $ex) {
echo '<h3>Unable to connect to database</h3>';
die($ex->getMessage());
}
2023-01-07 19:13:09 +00:00
2023-10-21 14:21:02 +00:00
$awk = new AwakiContext($db, $config->scopeTo('urls'));