aboutsummaryrefslogtreecommitdiff
path: root/index.php
diff options
context:
space:
mode:
authorLaria Carolin Chabowski <laria@laria.me>2020-02-07 09:44:59 +0100
committerLaria Carolin Chabowski <laria@laria.me>2020-02-07 09:44:59 +0100
commit2eb5a432d2229788ce2fdb09f36c6f4bebdea813 (patch)
treeab57978bdda34c82b025b897cfb6825b1fd1e654 /index.php
downloadmicropoly-2eb5a432d2229788ce2fdb09f36c6f4bebdea813.tar.gz
micropoly-2eb5a432d2229788ce2fdb09f36c6f4bebdea813.tar.bz2
micropoly-2eb5a432d2229788ce2fdb09f36c6f4bebdea813.zip
Initial commit
Diffstat (limited to 'index.php')
-rw-r--r--index.php25
1 files changed, 25 insertions, 0 deletions
diff --git a/index.php b/index.php
new file mode 100644
index 0000000..cf4c3cc
--- /dev/null
+++ b/index.php
@@ -0,0 +1,25 @@
+<?php
+
+use Micropoly\Entrypoint;
+use Micropoly\Main;
+
+function micropoly_main()
+{
+ if (php_sapi_name() == 'cli-server') {
+ if (preg_match('/^\/(assets|vendor\/components)/', $_SERVER["REQUEST_URI"]))
+ return false;
+ }
+
+ require_once "vendor/autoload.php";
+ $cls = Main::class;
+ if (php_sapi_name() === "cli" && isset($GLOBALS["argv"][1]))
+ $cls = $GLOBALS["argv"][1];
+
+ $obj = new $cls();
+ if (!($obj instanceof Entrypoint))
+ throw new Exception("$cls is not a " . Entrypoint::class);
+
+ $obj->run(\Micropoly\Env::fromConfig(require "config.php"));
+}
+
+return micropoly_main(); \ No newline at end of file