<?php
-use mdref\Action;
-use mdref\BaseUrl;
-use mdref\Reference;
-use mdref\ExceptionHandler;
+namespace mdref;
use http\Env\Request;
use http\Env\Response;
+use function ini_get;
+use function ini_set;
+use const GLOB_ONLYDIR;
+use const PATH_SEPARATOR;
+use const REFS;
+use const ROOT;
define("ROOT", dirname(__DIR__));
+define("REFS", getenv("REFPATH") ?: implode(PATH_SEPARATOR, glob(ROOT."/refs/*", GLOB_ONLYDIR)));
-#ini_set("open_basedir", ROOT.":".REFS);
+ini_set("open_basedir", ROOT.PATH_SEPARATOR.REFS);
-$loader = require ROOT . "/vendor/autoload.php";
-/* @var $loader \Composer\Autoload\ClassLoader */
-$loader->add("mdref", ROOT);
+if (!ini_get("date.timezone")) {
+ date_default_timezone_set("UTC");
+}
-new ExceptionHandler;
+require_once __DIR__ . "/../vendor/autoload.php";
-$reference = new Reference(($refs = getenv("REFPATH")) ? explode(PATH_SEPARATOR, $refs) : glob(ROOT."/refs/*"));
-$action = new Action($reference, new Request, new Response, new BaseUrl);
+$response = new Response;
+$ehandler = new ExceptionHandler($response);
+$reference = new Reference(explode(PATH_SEPARATOR, REFS));
+$action = new Action($reference, new Request, $response, new BaseUrl);
$action->handle();