fix cli-server
[mdref/mdref] / public / index.php
index 1e6d37f83bcf26f45822e31c68db7065f5d65b45..56cf3a27fb6119c75db0cd626237eed489fe6a5d 100644 (file)
@@ -1,27 +1,23 @@
 <?php
 
+use mdref\Action;
+use mdref\BaseUrl;
+use mdref\Reference;
+use mdref\ExceptionHandler;
+
+use http\Env\Request;
+use http\Env\Response;
+
 define("ROOT", dirname(__DIR__));
-define("REFS", getenv("REFPATH") ?: implode(PATH_SEPARATOR, glob(ROOT."/refs/*")));
 
-ini_set("open_basedir", ROOT.":".REFS);
+#ini_set("open_basedir", ROOT.":".REFS);
 
 $loader = require ROOT . "/vendor/autoload.php";
 /* @var $loader \Composer\Autoload\ClassLoader */
 $loader->add("mdref", ROOT);
 
-use http\Controller;
-use http\Controller\Url;
-use http\Controller\Observer\Layout;
-
-use mdref\ExceptionHandler;
-use mdref\Action;
-
 new ExceptionHandler;
 
-$ctl = new Controller;
-$ctl->setDependency("baseUrl", new Url)
-       ->attach(new Action(["refpath" => REFS]))
-       ->attach(new Layout)
-       ->notify()
-       ->getResponse()
-       ->send();
+$reference = new Reference(($refs = getenv("REFPATH")) ? explode(PATH_SEPARATOR, $refs) : glob(ROOT."/refs/*"));
+$action = new Action($reference, new Request, new Response, new BaseUrl);
+$action->handle();