private function getURIFromEnvironment($options)
    {
        $uri = $this->getOption($options, 'uri');
        if (!$uri) { // use given URI in config options
            if (isset($_SERVER['REDIRECT_URL']) && isset($_SERVER['SCRIPT_NAME'])) { // use redirection URL from Apache environment
                $dirname = dirname($_SERVER['SCRIPT_NAME']);
                $uri = substr($_SERVER['REDIRECT_URL'], strlen($dirname == DIRECTORY_SEPARATOR ? '' : $dirname));
            } elseif (isset($_SERVER['REQUEST_URI'])) { // use request URI from environment
                $uri = parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH);
            } elseif (isset($_SERVER['PHP_SELF']) && isset($_SERVER['SCRIPT_NAME'])) { // use PHP_SELF from Apache environment
                $uri = substr($_SERVER['PHP_SELF'], strlen($_SERVER['SCRIPT_NAME']));
            } else { // fail
                throw new \Exception('URI not provided');
            }
        }

        // get mimetype
        $parts = explode('/', $uri);
        $lastPart = array_pop($parts);
        $uri = join('/', $parts);

        $parts = explode('.', $lastPart);
        $firstPart = array_shift($parts);
        $uri .= '/'.$firstPart;

        foreach ($parts as $part) {
            if (isset($this->mimetypes[$part])) {
                $this->accept[] = $this->mimetypes[$part];
            } elseif (preg_match('/^[a-z]{2}(-[a-z]{2})?$/', $part)) {
                $this->acceptLanguage[] = $part;
            } else {
                $uri .= '.'.$part;
            }
        }

        return $uri;
    }
private function getURIFromEnvironment($options)
    {
        $uri = $this->getOption($options, 'uri');
        if (!$uri) { // use given URI in config options
            if (isset($_SERVER['REDIRECT_URL']) && isset($_SERVER['SCRIPT_NAME'])) { // use redirection URL from Apache environment
                $dirname = dirname($_SERVER['SCRIPT_NAME']);
                $uri = substr($_SERVER['REDIRECT_URL'], strlen($dirname == DIRECTORY_SEPARATOR ? '' : $dirname));
            } elseif (isset($_SERVER['REQUEST_URI'])) { // use request URI from environment
                $uri = parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH);
            } elseif (isset($_SERVER['PHP_SELF']) && isset($_SERVER['SCRIPT_NAME'])) { // use PHP_SELF from Apache environment
                $uri = substr($_SERVER['PHP_SELF'], strlen($_SERVER['SCRIPT_NAME']));
            } else { // fail
                throw new \Exception('URI not provided');
            }
        }

        // get mimetype
        $parts = explode('/', $uri);
        $lastPart = array_pop($parts);
        $uri = join('/', $parts);

        $parts = explode('.', $lastPart);
        $firstPart = array_shift($parts);
        $uri .= '/'.$firstPart;

        foreach ($parts as $part) {
            if (isset($this->mimetypes[$part])) {
                $this->accept[] = $this->mimetypes[$part];
            } elseif (preg_match('/^[a-z]{2}(-[a-z]{2})?$/', $part)) {
                $this->acceptLanguage[] = $part;
            } else {
                $uri .= '.'.$part;
            }
        }

        return $uri;
    }
private function getURIFromEnvironment ( $ options ) { $ uri = $ this -> getOption ( $ options , 'uri' ) ; if ( ! $ uri ) { // use given URI in config options if ( isset ( $ _SERVER [ 'REDIRECT_URL' ] ) && isset ( $ _SERVER [ 'SCRIPT_NAME' ] ) ) { // use redirection URL from Apache environment $ dirname = dirname ( $ _SERVER [ 'SCRIPT_NAME' ] ) ; $ uri = substr ( $ _SERVER [ 'REDIRECT_URL' ] , strlen ( $ dirname == DIRECTORY_SEPARATOR ? '' : $ dirname ) ) ; } elseif ( isset ( $ _SERVER [ 'REQUEST_URI' ] ) ) { // use request URI from environment $ uri = parse_url ( $ _SERVER [ 'REQUEST_URI' ] , PHP_URL_PATH ) ; } elseif ( isset ( $ _SERVER [ 'PHP_SELF' ] ) && isset ( $ _SERVER [ 'SCRIPT_NAME' ] ) ) { // use PHP_SELF from Apache environment $ uri = substr ( $ _SERVER [ 'PHP_SELF' ] , strlen ( $ _SERVER [ 'SCRIPT_NAME' ] ) ) ; } else { // fail throw new \ Exception ( 'URI not provided' ) ; } } // get mimetype $ parts = explode ( '/' , $ uri ) ; $ lastPart = array_pop ( $ parts ) ; $ uri = join ( '/' , $ parts ) ; $ parts = explode ( '.' , $ lastPart ) ; $ firstPart = array_shift ( $ parts ) ; $ uri .= '/' . $ firstPart ; foreach ( $ parts as $ part ) { if ( isset ( $ this -> mimetypes [ $ part ] ) ) { $ this -> accept [ ] = $ this -> mimetypes [ $ part ] ; } elseif ( preg_match ( '/^[a-z]{2}(-[a-z]{2})?$/' , $ part ) ) { $ this -> acceptLanguage [ ] = $ part ; } else { $ uri .= '.' . $ part ; } } return $ uri ; }
Fetch the request URI from the server environment
@param  str $options
@return str
Fetch the request URI from the server environment