hanyuu/hanyuu.php

49 lines
1.4 KiB
PHP
Raw Normal View History

2023-01-06 22:20:13 +00:00
<?php
namespace Hanyuu;
use Index\Autoloader;
use Index\Environment;
use Hanyuu\Config\ArrayConfig;
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_PUBLIC', HAU_ROOT . '/public');
define('HAU_DIR_SOURCE', HAU_ROOT . '/src');
define('HAU_DIR_LIBRARIES', HAU_ROOT . '/lib');
define('HAU_DIR_CONFIG', HAU_ROOT . '/config');
2023-01-07 04:36:22 +00:00
define('HAU_DIR_MIGRATIONS', HAU_ROOT . '/database');
define('HAU_DIR_TEMPLATES', HAU_ROOT . '/templates');
2023-01-06 22:20:13 +00:00
define('HAU_NDX_PATH', HAU_DIR_LIBRARIES . '/index');
define('HAU_NDX_PATH_DEV', HAU_DIR_LIBRARIES . '/index-dev');
require_once (HAU_DEBUG && is_dir(HAU_NDX_PATH_DEV) ? HAU_NDX_PATH_DEV : HAU_NDX_PATH) . '/index.php';
Autoloader::addNamespace(__NAMESPACE__, HAU_DIR_SOURCE);
Environment::setDebug(HAU_DEBUG);
mb_internal_encoding('utf-8');
date_default_timezone_set('utc');
set_include_path(get_include_path() . PATH_SEPARATOR . HAU_ROOT);
set_exception_handler(function(\Throwable $ex) {
if(HAU_CLI)
die((string)$ex);
http_response_code(500);
ob_clean();
if(HAU_DEBUG) {
header('Content-Type: text/plain; charset=utf-8');
die((string)$ex);
}
header('Content-Type: text/html; charset-utf-8');
die('<h2>Hanyuu is sad.</h2>');
});
$hau = new HanyuuContext(ArrayConfig::open(HAU_DIR_CONFIG . '/config.ini'));
$hau->connectDb();