/** * Creates a response with a header to redirect * * @param string * @param int * @return object */ public static function redirect($uri, $status = 302) { // Scrub all output buffer before we redirect. // @see http://www.mombu.com/php/php/t-output-buffering-and-zlib-compression-issue-3554315-last.html while (ob_get_level() > 1) { ob_end_clean(); } return static::create('', $status, array('Location' => Uri::to($uri))); }
/** * Create a new instance of the Router class for chaining * * @return object */ public static function create() { if (Request::cli()) { // get cli arguments $args = Arr::get($_SERVER, 'argv', array()); $uri = implode('/', array_slice($args, 1)); return new static('cli', trim($uri, '/') ?: '/'); } return new static(Request::method(), Uri::current()); }