generate static pages with league/commonmark
[mdref/mdref] / public / index.php
index e6d0f75a4ce4a9fe449d1cd92c8f81c97b9c7570..65ad2d2e033f457b91500e7a444d65fd46c9b450 100644 (file)
@@ -1,15 +1,18 @@
 <?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/*")));
+define("REFS", getenv("REFPATH") ?: implode(PATH_SEPARATOR, glob(ROOT."/refs/*", GLOB_ONLYDIR)));
 
 ini_set("open_basedir", ROOT.PATH_SEPARATOR.REFS);
 
@@ -17,11 +20,7 @@ if (!ini_get("date.timezone")) {
        date_default_timezone_set("UTC");
 }
 
-spl_autoload_register(function($c) {
-       if (!strncmp($c, "mdref\\", 6)) {
-               return require ROOT . "/" . strtr($c, "\\", "/") . ".php";
-       }
-});
+require_once __DIR__ . "/../vendor/autoload.php";
 
 $response = new Response;
 $ehandler = new ExceptionHandler($response);