/** * "Forward" the request * * This driver is great for a single server install, * and when debugging your application. * * @param string $method GET, POST, PUT, DELETE, etc. * @param array $segments for example array('account', 'all') * @param array $data the post / put data */ public static function request($method, $segments, $data = array()) { $method = strtoupper($method); if (in_array($method, array('GET', 'POST', 'PUT', 'DELETE'))) { Input::replace($data); } $config = static::config(); $_SERVER['PHP_AUTH_USER'] = $config['username']; $_SERVER['PHP_AUTH_PW'] = $config['password']; list($url, $uri, $query_string) = static::url($segments, $data); $prefix = Config::get('layla.domain.url_prefix'); if (!is_null($prefix)) { $prefix .= '/'; } $response = Route::forward($method, $prefix . $uri); $code = $response->foundation->getStatusCode(); $body = $response->content; return new Response($code, json_decode($body)); }