aboutsummaryrefslogtreecommitdiff
path: root/index.php
blob: cf4c3cce4970fc23b3a73f434965c0024d205478 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
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();