src/Colorium/Http/Uri.php
public static function current($base = null)
    {
        static $current;
        if(!$current) {

            // parse server header
            $scheme = isset($_SERVER['REQUEST_SCHEME']) ? $_SERVER['REQUEST_SCHEME'] : null;
            $host = isset($_SERVER['HTTP_HOST']) ? $_SERVER['HTTP_HOST'] : null;
            $path = isset($_SERVER['REQUEST_URI']) ? $_SERVER['REQUEST_URI'] : null;
            $query = parse_url($path, PHP_URL_QUERY);
            $path = parse_url($path, PHP_URL_PATH);

            // auto-resolve base path
            if(!$base) {
                if(!empty($_SERVER['HTTP_BASE_URI'])) {
                    $base = $_SERVER['HTTP_BASE_URI'];
                }
                elseif(isset($_SERVER['SCRIPT_NAME']) and $scriptname = dirname($_SERVER['SCRIPT_NAME'])) {
                    $scriptname = trim($scriptname, '.');
                    while($scriptname and $scriptname != '/') {
                        if(strncmp($path, $scriptname, strlen($scriptname)) === 0) {
                            $base = $scriptname;
                            break;
                        }
                        $scriptname = dirname($scriptname);
                    }
                }
            }

            $current = new static([
                'scheme' => $scheme,
                'user' => null,
                'pass' => null,
                'host' => $host,
                'port' => null,
                'base' => $base,
                'path' => $path,
                'query' => $query,
                'fragment' => null,
            ]);
        }

        return $current;
    }
public static function current($base = null)
    {
        static $current;
        if(!$current) {

            // parse server header
            $scheme = isset($_SERVER['REQUEST_SCHEME']) ? $_SERVER['REQUEST_SCHEME'] : null;
            $host = isset($_SERVER['HTTP_HOST']) ? $_SERVER['HTTP_HOST'] : null;
            $path = isset($_SERVER['REQUEST_URI']) ? $_SERVER['REQUEST_URI'] : null;
            $query = parse_url($path, PHP_URL_QUERY);
            $path = parse_url($path, PHP_URL_PATH);

            // auto-resolve base path
            if(!$base) {
                if(!empty($_SERVER['HTTP_BASE_URI'])) {
                    $base = $_SERVER['HTTP_BASE_URI'];
                }
                elseif(isset($_SERVER['SCRIPT_NAME']) and $scriptname = dirname($_SERVER['SCRIPT_NAME'])) {
                    $scriptname = trim($scriptname, '.');
                    while($scriptname and $scriptname != '/') {
                        if(strncmp($path, $scriptname, strlen($scriptname)) === 0) {
                            $base = $scriptname;
                            break;
                        }
                        $scriptname = dirname($scriptname);
                    }
                }
            }

            $current = new static([
                'scheme' => $scheme,
                'user' => null,
                'pass' => null,
                'host' => $host,
                'port' => null,
                'base' => $base,
                'path' => $path,
                'query' => $query,
                'fragment' => null,
            ]);
        }

        return $current;
    }
Generate uri from $_SERVER

@param string $base
@return static