uiharu/uiharu.php

39 lines
988 B
PHP
Raw Normal View History

2022-07-14 20:42:37 +00:00
<?php
namespace Uiharu;
use Index\Environment;
use Index\Data\ConnectionFailedException;
use Index\Data\DbTools;
define('UIH_STARTUP', microtime(true));
define('UIH_ROOT', __DIR__);
define('UIH_DEBUG', is_file(UIH_ROOT . '/.debug'));
define('UIH_PUBLIC', UIH_ROOT . '/public');
define('UIH_SOURCE', UIH_ROOT . '/src');
define('UIH_LIBRARY', UIH_ROOT . '/lib');
2023-10-21 14:35:09 +00:00
define('UIH_VERSION', '20231021');
2022-07-14 20:42:37 +00:00
2023-10-21 14:35:09 +00:00
require_once UIH_ROOT . '/vendor/autoload.php';
2022-07-14 20:42:37 +00:00
Environment::setDebug(UIH_DEBUG);
mb_internal_encoding('utf-8');
date_default_timezone_set('utc');
$configPath = UIH_ROOT . '/config.ini';
if(!is_file($configPath))
die('Uiharu configuration is missing.');
Config::load($configPath);
if(!Config::has('Database', 'dsn'))
die('Uiharu database is not configured.');
try {
$db = DbTools::create(Config::get('Database', 'dsn'));
} catch(ConnectionFailedException $ex) {
echo '<h3>Unable to connect to database</h3>';
die($ex->getMessage());
}
$ctx = new UihContext($db);