protected function parsePaths()
    {
        if (is_null($this->paths) === true) {
            // Server params
            $scriptName = $this->env->get('SCRIPT_NAME'); // <-- "/foo/index.php"
            $requestUri = $this->env->get('REQUEST_URI'); // <-- "/foo/bar?test=abc" or "/foo/index.php/bar?test=abc"
            $queryString = $this->getQueryString(); // <-- "test=abc" or ""

            // Physical path
            if (strpos($requestUri, $scriptName) !== false) {
                $physicalPath = $scriptName; // <-- Without rewriting
            } else {
                $physicalPath = str_replace('\\', '', dirname($scriptName)); // <-- With rewriting
            }
            $scriptName = rtrim($physicalPath, '/'); // <-- Remove trailing slashes

            // Virtual path
            $pathInfo = substr_replace($requestUri, '', 0, strlen($physicalPath)); // <-- Remove physical path
            $pathInfo = str_replace('?' . $queryString, '', $pathInfo); // <-- Remove query string
            $pathInfo = '/' . ltrim($pathInfo, '/'); // <-- Ensure leading slash

            $this->paths = array();
            $this->paths['physical'] = $scriptName;
            $this->paths['virtual'] = $pathInfo;
        }

        return $this->paths;
    }
protected function parsePaths()
    {
        if (is_null($this->paths) === true) {
            // Server params
            $scriptName = $this->env->get('SCRIPT_NAME'); // <-- "/foo/index.php"
            $requestUri = $this->env->get('REQUEST_URI'); // <-- "/foo/bar?test=abc" or "/foo/index.php/bar?test=abc"
            $queryString = $this->getQueryString(); // <-- "test=abc" or ""

            // Physical path
            if (strpos($requestUri, $scriptName) !== false) {
                $physicalPath = $scriptName; // <-- Without rewriting
            } else {
                $physicalPath = str_replace('\\', '', dirname($scriptName)); // <-- With rewriting
            }
            $scriptName = rtrim($physicalPath, '/'); // <-- Remove trailing slashes

            // Virtual path
            $pathInfo = substr_replace($requestUri, '', 0, strlen($physicalPath)); // <-- Remove physical path
            $pathInfo = str_replace('?' . $queryString, '', $pathInfo); // <-- Remove query string
            $pathInfo = '/' . ltrim($pathInfo, '/'); // <-- Ensure leading slash

            $this->paths = array();
            $this->paths['physical'] = $scriptName;
            $this->paths['virtual'] = $pathInfo;
        }

        return $this->paths;
    }
protected function parsePaths ( ) { if ( is_null ( $ this -> paths ) === true ) { // Server params $ scriptName = $ this -> env -> get ( 'SCRIPT_NAME' ) ; // <-- "/foo/index.php" $ requestUri = $ this -> env -> get ( 'REQUEST_URI' ) ; // <-- "/foo/bar?test=abc" or "/foo/index.php/bar?test=abc" $ queryString = $ this -> getQueryString ( ) ; // <-- "test=abc" or "" // Physical path if ( strpos ( $ requestUri , $ scriptName ) !== false ) { $ physicalPath = $ scriptName ; // <-- Without rewriting } else { $ physicalPath = str_replace ( '\\' , '' , dirname ( $ scriptName ) ) ; // <-- With rewriting } $ scriptName = rtrim ( $ physicalPath , '/' ) ; // <-- Remove trailing slashes // Virtual path $ pathInfo = substr_replace ( $ requestUri , '' , 0 , strlen ( $ physicalPath ) ) ; // <-- Remove physical path $ pathInfo = str_replace ( '?' . $ queryString , '' , $ pathInfo ) ; // <-- Remove query string $ pathInfo = '/' . ltrim ( $ pathInfo , '/' ) ; // <-- Ensure leading slash $ this -> paths = array ( ) ; $ this -> paths [ 'physical' ] = $ scriptName ; $ this -> paths [ 'virtual' ] = $ pathInfo ; } return $ this -> paths ; }
Parse the physical and virtual paths from the request URI

@return array
Parse the physical and virtual paths from the request URI