public static function createFromGlobals(array $globals)
    {
        $g   = &$globals;
        $App = $g['App'] ?? null;

        if (!($App instanceof Classes\App)) {
            throw new Exception('Missing App.');
        }
        unset($g['App']); // Ditch this.

        foreach ($g as $_key => $_value) {
            if (mb_stripos((string) $_key, 'CFG_') === 0) {
                unset($g[$_key]);
            }
        } // unset($_key, $_value);

        $method         = $g['REQUEST_METHOD'] ?? '';
        $Uri            = Uri::createFromGlobals($g);
        $Headers        = Headers::createFromGlobals($g);
        $cookies        = Cookies::parseHeader($Headers->get('cookie', []));
        $server_params  = $g; // Simply a copy of globals.
        $Body           = $App->c::createRequestBody();
        $uploaded_files = UploadedFile::createFromGlobals($g);

        $Request = new static($App, $method, $Uri, $Headers, $cookies, $server_params, $Body, $uploaded_files);

        if ($method === 'POST' && in_array($Request->getMediaType(), ['application/x-www-form-urlencoded', 'multipart/form-data'])) {
            $Request = $Request->withParsedBody($_POST);
        }
        return $Request;
    }
public static function createFromGlobals(array $globals)
    {
        $g   = &$globals;
        $App = $g['App'] ?? null;

        if (!($App instanceof Classes\App)) {
            throw new Exception('Missing App.');
        }
        unset($g['App']); // Ditch this.

        foreach ($g as $_key => $_value) {
            if (mb_stripos((string) $_key, 'CFG_') === 0) {
                unset($g[$_key]);
            }
        } // unset($_key, $_value);

        $method         = $g['REQUEST_METHOD'] ?? '';
        $Uri            = Uri::createFromGlobals($g);
        $Headers        = Headers::createFromGlobals($g);
        $cookies        = Cookies::parseHeader($Headers->get('cookie', []));
        $server_params  = $g; // Simply a copy of globals.
        $Body           = $App->c::createRequestBody();
        $uploaded_files = UploadedFile::createFromGlobals($g);

        $Request = new static($App, $method, $Uri, $Headers, $cookies, $server_params, $Body, $uploaded_files);

        if ($method === 'POST' && in_array($Request->getMediaType(), ['application/x-www-form-urlencoded', 'multipart/form-data'])) {
            $Request = $Request->withParsedBody($_POST);
        }
        return $Request;
    }
public static function createFromGlobals ( array $ globals ) { $ g = & $ globals ; $ App = $ g [ 'App' ] ?? null ; if ( ! ( $ App instanceof Classes \ App ) ) { throw new Exception ( 'Missing App.' ) ; } unset ( $ g [ 'App' ] ) ; // Ditch this. foreach ( $ g as $ _key => $ _value ) { if ( mb_stripos ( ( string ) $ _key , 'CFG_' ) === 0 ) { unset ( $ g [ $ _key ] ) ; } } // unset($_key, $_value); $ method = $ g [ 'REQUEST_METHOD' ] ?? '' ; $ Uri = Uri :: createFromGlobals ( $ g ) ; $ Headers = Headers :: createFromGlobals ( $ g ) ; $ cookies = Cookies :: parseHeader ( $ Headers -> get ( 'cookie' , [ ] ) ) ; $ server_params = $ g ; // Simply a copy of globals. $ Body = $ App -> c :: createRequestBody ( ) ; $ uploaded_files = UploadedFile :: createFromGlobals ( $ g ) ; $ Request = new static ( $ App , $ method , $ Uri , $ Headers , $ cookies , $ server_params , $ Body , $ uploaded_files ) ; if ( $ method === 'POST' && in_array ( $ Request -> getMediaType ( ) , [ 'application/x-www-form-urlencoded' , 'multipart/form-data' ] ) ) { $ Request = $ Request -> withParsedBody ( $ _POST ) ; } return $ Request ; }
Create from globals.

@since 17xxxx Request object.

@param array $globals Globals.

@return Request Instance from globals.
Create from globals .