src/Mvc/Controller/Request.php
public static function parse($uri, $serverVars = array(), $defaultController = 'Index', $defaultAction = 'index')
    {
        $req = new self($defaultController, $defaultAction);
        $req->origin = $uri;
        
        self::parseRemoteHost($req, $serverVars);
        
        self::parseGetPostSessionCookie($req);
        
        // Save the request parameters for later usage and rewrite the uri
        $savedRequestParams = array();
        if (strpos($uri, '?')) {
            parse_str(substr($uri, strpos($uri, '?') + 1), $savedRequestParams);
            $uri = substr($uri, 0, strpos($uri, '?'));
        }
        
        self::parseContextPrefix($req, $serverVars);
        
        $parts = self::parseUri($req, $uri, $defaultController, $defaultAction);
        
        // Walk over all parameters and put them into container
        $numParts = count($parts);
        for ($i = 0; $i < $numParts; $i = $i + 2) {
            $paramName = trim($parts[$i]);
            $paramValue = isset($parts[$i + 1]) ? trim($parts[$i + 1]) : '';
            if ($paramName && $paramValue) {
                $req->params[$paramName] = $paramValue;
            }
        }
        
        $req->params = array_merge($req->params, $savedRequestParams);
        
        self::parseParameters($req, $serverVars);
        
        // Et'voila
        return $req;
    }
public static function parse($uri, $serverVars = array(), $defaultController = 'Index', $defaultAction = 'index')
    {
        $req = new self($defaultController, $defaultAction);
        $req->origin = $uri;
        
        self::parseRemoteHost($req, $serverVars);
        
        self::parseGetPostSessionCookie($req);
        
        // Save the request parameters for later usage and rewrite the uri
        $savedRequestParams = array();
        if (strpos($uri, '?')) {
            parse_str(substr($uri, strpos($uri, '?') + 1), $savedRequestParams);
            $uri = substr($uri, 0, strpos($uri, '?'));
        }
        
        self::parseContextPrefix($req, $serverVars);
        
        $parts = self::parseUri($req, $uri, $defaultController, $defaultAction);
        
        // Walk over all parameters and put them into container
        $numParts = count($parts);
        for ($i = 0; $i < $numParts; $i = $i + 2) {
            $paramName = trim($parts[$i]);
            $paramValue = isset($parts[$i + 1]) ? trim($parts[$i + 1]) : '';
            if ($paramName && $paramValue) {
                $req->params[$paramName] = $paramValue;
            }
        }
        
        $req->params = array_merge($req->params, $savedRequestParams);
        
        self::parseParameters($req, $serverVars);
        
        // Et'voila
        return $req;
    }
Parse an uri into its request parts

@param string $uri
The uri to parse

@param array $serverVars
The variables provided by sapi

@param string $defaultController
The name of the default controller if nothing else is requested

@param string $defaultAction
The name of the default action if nothing else is requested

@return \Nkey\Caribu\Mvc\Controller\Request The new created request