当前位置: 首页>>代码示例>>PHP>>正文


PHP Request::uri方法代码示例

本文整理汇总了PHP中Request::uri方法的典型用法代码示例。如果您正苦于以下问题:PHP Request::uri方法的具体用法?PHP Request::uri怎么用?PHP Request::uri使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Request的用法示例。


在下文中一共展示了Request::uri方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: testGet

 /**
  * @todo Implement testGet().
  */
 public function testGet()
 {
     $response = $this->presta->uri('http://example.com')->get();
     $entity_body = $response->entity_body;
     $this->assertTrue(!empty($entity_body), "No Entity Body returned");
     $this->assertTrue($response->status_code == '200', "Response code expected 200, found [" . $response->header('status_code') . "]");
 }
开发者ID:samkeen,项目名称:presta,代码行数:10,代码来源:RequestTest.php

示例2: _send_message

 /**
  * Sends the HTTP message [Request] to a remote server and processes
  * the response.
  *
  * @param   Request   $request  request to send
  * @param   Response  $request  response to send
  * @return  Response
  */
 public function _send_message(Request $request, Response $response)
 {
     $http_method_mapping = array(HTTP_Request::GET => HTTPRequest::METH_GET, HTTP_Request::HEAD => HTTPRequest::METH_HEAD, HTTP_Request::POST => HTTPRequest::METH_POST, HTTP_Request::PUT => HTTPRequest::METH_PUT, HTTP_Request::DELETE => HTTPRequest::METH_DELETE, HTTP_Request::OPTIONS => HTTPRequest::METH_OPTIONS, HTTP_Request::TRACE => HTTPRequest::METH_TRACE, HTTP_Request::CONNECT => HTTPRequest::METH_CONNECT);
     // Create an http request object
     $http_request = new HTTPRequest($request->uri(), $http_method_mapping[$request->method()]);
     if ($this->_options) {
         // Set custom options
         $http_request->setOptions($this->_options);
     }
     // Set headers
     $http_request->setHeaders($request->headers()->getArrayCopy());
     // Set cookies
     $http_request->setCookies($request->cookie());
     // Set query data (?foo=bar&bar=foo)
     $http_request->setQueryData($request->query());
     // Set the body
     if ($request->method() == HTTP_Request::PUT) {
         $http_request->addPutData($request->body());
     } else {
         $http_request->setBody($request->body());
     }
     try {
         $http_request->send();
     } catch (HTTPRequestException $e) {
         throw new Request_Exception($e->getMessage());
     } catch (HTTPMalformedHeaderException $e) {
         throw new Request_Exception($e->getMessage());
     } catch (HTTPEncodingException $e) {
         throw new Request_Exception($e->getMessage());
     }
     // Build the response
     $response->status($http_request->getResponseCode())->headers($http_request->getResponseHeader())->cookie($http_request->getResponseCookies())->body($http_request->getResponseBody());
     return $response;
 }
开发者ID:artbypravesh,项目名称:morningpages,代码行数:42,代码来源:HTTP.php

示例3: __construct

 public function __construct()
 {
     parent::__construct();
     if (Request::uri() !== 'ajax/project/issue_upload_attachment') {
         $this->filter('before', 'auth');
     }
 }
开发者ID:eliasyanni,项目名称:bugs,代码行数:7,代码来源:base.php

示例4: render

 public static function render($template, $data = array())
 {
     // get default theme
     $theme = Config::get('metadata.theme');
     // load global theming functions but not for the admin template
     if (strpos(static::$path, 'system/admin/theme') === false) {
         $includes = array('articles', 'comments', 'config', 'helpers', 'menus', 'metadata', 'pages', 'posts', 'search', 'users');
         foreach ($includes as $file) {
             require PATH . 'system/functions/' . $file . '.php';
         }
     }
     // load theme functions
     if (file_exists(static::$path . 'functions.php')) {
         require static::$path . 'functions.php';
     }
     // render files
     foreach (array('includes/header', $template, 'includes/footer') as $file) {
         $filepath = static::$path . $file . '.php';
         //  Nasty hack, but hey, we've got custom pages now.
         if ($file === 'page' and file_exists(static::$path . Request::uri() . '.php') !== false) {
             $filepath = static::$path . Request::uri() . '.php';
         }
         if (file_exists($filepath) === false) {
             throw new ErrorException('Theme file <strong>themes/' . $theme . '/' . $file . '.php</strong> not found.');
         }
         static::parse($filepath, $data);
     }
 }
开发者ID:nathggns,项目名称:anchor-cms,代码行数:28,代码来源:template.php

示例5: execute

 public function execute(Request $request)
 {
     if ($this->callback_depth() > $this->max_callback_depth()) {
         throw new Request_Client_Recursion_Exception("Could not execute request to :uri - too many recursions after :depth requests", array(":uri" => $request->uri(), ":depth" => $this->callback_depth() - 1));
     }
     $orig_response = $response = Response::factory(array("_protocol" => $request->protocol()));
     if (($cache = $this->cache()) instanceof HTTP_Cache) {
         return $cache->execute($this, $request, $response);
     }
     $response = $this->execute_request($request, $response);
     foreach ($this->header_callbacks() as $header => $callback) {
         if ($response->headers($header)) {
             $cb_result = call_user_func($callback, $request, $response, $this);
             if ($cb_result instanceof Request) {
                 $this->assign_client_properties($cb_result->client());
                 $cb_result->client()->callback_depth($this->callback_depth() + 1);
                 $response = $cb_result->execute();
             } elseif ($cb_result instanceof Response) {
                 $response = $cb_result;
             }
             if ($response !== $orig_response) {
                 break;
             }
         }
     }
     return $response;
 }
开发者ID:benshez,项目名称:DreamWeddingCeremomies,代码行数:27,代码来源:Client.php

示例6: parse

 private static function parse()
 {
     // get uri
     $uri = Request::uri();
     // lets log our initial uri
     Log::info('Requested URI: ' . $uri);
     // route definitions
     $routes = array();
     // posts host page
     if ($page = IoC::resolve('posts_page')) {
         $routes[$page->slug . '/(:any)'] = 'article/$1';
     }
     // fallback to 'admin'
     $admin_folder = Config::get('application.admin_folder', 'admin');
     // static routes
     $routes = array_merge($routes, array($admin_folder . '/(:any)/(:any)/(:any)' => 'admin/$1/$2/$3', $admin_folder . '/(:any)/(:any)' => 'admin/$1/$2', $admin_folder . '/(:any)' => 'admin/$1', $admin_folder => 'admin', 'search/(:any)' => 'search/$1', 'search' => 'search', 'rss' => 'rss', '(:any)' => 'page/$1'));
     // define wild-cards
     $search = array(':any', ':num');
     $replace = array('[0-9a-zA-Z~%\\.:_\\-]+', '[0-9]+');
     // parse routes
     foreach ($routes as $route => $translated) {
         // replace wildcards
         $route = str_replace($search, $replace, $route);
         // look for matches
         if (preg_match('#^' . $route . '#', $uri, $matches)) {
             // replace matched values
             foreach ($matches as $k => $match) {
                 $translated = str_replace('$' . $k, $match, $translated);
             }
             // return on first match
             return $translated;
         }
     }
     return $uri;
 }
开发者ID:nathggns,项目名称:anchor-cms,代码行数:35,代码来源:anchor.php

示例7: basic_cache_key_generator

 /**
  * Basic cache key generator that hashes the entire request and returns
  * it. This is fine for static content, or dynamic content where user
  * specific information is encoded into the request.
  * 
  *      // Generate cache key
  *      $cache_key = HTTP_Cache::basic_cache_key_generator($request);
  *
  * @param   Request $request
  * @return  string
  */
 public static function basic_cache_key_generator(Request $request)
 {
     $uri = $request->uri();
     $query = $request->query();
     $headers = $request->headers()->getArrayCopy();
     $body = $request->body();
     return sha1($uri . '?' . http_build_query($query, NULL, '&') . '~' . implode('~', $headers) . '~' . $body);
 }
开发者ID:robert-kampas,项目名称:games-collection-manager,代码行数:19,代码来源:Cache.php

示例8: __construct

 function __construct()
 {
     echo 'Install::App started!<br>';
     echo Request::uri();
     echo '?page=', Request::get('page', 1, false);
     $layout = Responce::layout('start');
     $layout->title('Test page!');
 }
开发者ID:nvlad,项目名称:framework,代码行数:8,代码来源:App.php

示例9: __construct

 public function __construct(Request $request)
 {
     // Delete the authorization
     cookie::delete('authorized');
     // Redirect to the login page
     $request->redirect(url::site($request->uri(array('controller' => NULL))));
     // Do not call anything here, redirect has already halted execution.
 }
开发者ID:pitchinvasion,项目名称:monobrow,代码行数:8,代码来源:logout.php

示例10: _send_message

 /**
  * Sends the HTTP message [Request] to a remote server and processes
  * the response.
  *
  * @param   Request   request to send
  * @return  Response
  */
 public function _send_message(Request $request)
 {
     // Response headers
     $response_headers = array();
     // Set the request method
     $options[CURLOPT_CUSTOMREQUEST] = $request->method();
     // Set the request body. This is perfectly legal in CURL even
     // if using a request other than POST. PUT does support this method
     // and DOES NOT require writing data to disk before putting it, if
     // reading the PHP docs you may have got that impression. SdF
     $options[CURLOPT_POSTFIELDS] = $request->body();
     // Process headers
     if ($headers = $request->headers()) {
         $http_headers = array();
         foreach ($headers as $key => $value) {
             $http_headers[] = $key . ': ' . $value;
         }
         $options[CURLOPT_HTTPHEADER] = $http_headers;
     }
     // Process cookies
     if ($cookies = $request->cookie()) {
         $options[CURLOPT_COOKIE] = http_build_query($cookies, NULL, '; ');
     }
     // Create response
     $response = $request->create_response();
     $response_header = $response->headers();
     // Implement the standard parsing parameters
     $options[CURLOPT_HEADERFUNCTION] = array($response_header, 'parse_header_string');
     $this->_options[CURLOPT_RETURNTRANSFER] = TRUE;
     $this->_options[CURLOPT_HEADER] = FALSE;
     // Apply any additional options set to
     $options += $this->_options;
     $uri = $request->uri();
     if ($query = $request->query()) {
         $uri .= '?' . http_build_query($query, NULL, '&');
     }
     // Open a new remote connection
     $curl = curl_init($uri);
     // Set connection options
     if (!curl_setopt_array($curl, $options)) {
         throw new Request_Exception('Failed to set CURL options, check CURL documentation: :url', array(':url' => 'http://php.net/curl_setopt_array'));
     }
     // Get the response body
     $body = curl_exec($curl);
     // Get the response information
     $code = curl_getinfo($curl, CURLINFO_HTTP_CODE);
     if ($body === FALSE) {
         $error = curl_error($curl);
     }
     // Close the connection
     curl_close($curl);
     if (isset($error)) {
         throw new Request_Exception('Error fetching remote :url [ status :code ] :error', array(':url' => $request->url(), ':code' => $code, ':error' => $error));
     }
     $response->status($code)->body($body);
     return $response;
 }
开发者ID:gilyaev,项目名称:framework-bench,代码行数:64,代码来源:curl.php

示例11: call

 public static function call($name = '')
 {
     $page = basename(Request::uri());
     if (empty($name)) {
         $name = 'main';
     }
     if ($func = isset(static::$stack[$page][$name]) ? static::$stack[$page][$name] : false) {
         return is_callable($func) ? $func() : '';
     }
     return '';
 }
开发者ID:reqshark,项目名称:anchor-cms,代码行数:11,代码来源:events.php

示例12: calculate_hmac

 /**
  * Calculate the signature of a request.
  * Should be called just before the request is sent.
  *
  * @param Request $request
  * @param $private_key
  * @return string Calculated HMAC
  */
 public static function calculate_hmac(Request $request, $private_key)
 {
     // Consolidate data that's not in the main route (params)
     $query = array_change_key_case($request->query());
     $post = array_change_key_case($request->post());
     // Sort alphabetically
     ksort($query);
     ksort($post);
     $data_to_sign = ['method' => $request->method(), 'uri' => $request->uri(), 'post' => $post, 'query' => $query];
     // Calculate the signature
     return hash_hmac('sha256', json_encode($data_to_sign), $private_key);
 }
开发者ID:anroots,项目名称:kohana-hapi,代码行数:20,代码来源:Security.php

示例13: matches

 /**
  * Tests if the route matches a given URI. A successful match will return
  * all of the routed parameters as an array. A failed match will return
  * boolean FALSE.
  *
  *     // Params: controller = users, action = edit, id = 10
  *     $params = $route->matches('users/edit/10');
  *
  * This method should almost always be used within an if/else block:
  *
  *     if ($params = $route->matches($uri))
  *     {
  *         // Parse the parameters
  *     }
  *
  * @param   string  $uri    URI to match
  * @return  array   on success
  * @return  FALSE   on failure
  */
 public function matches(Request $request)
 {
     // Get the URI from the Request
     $uri = trim($request->uri(), '/');
     if (!preg_match($this->_route_regex, $uri, $matches)) {
         return FALSE;
     }
     $params = array();
     foreach ($matches as $key => $value) {
         if (is_int($key)) {
             // Skip all unnamed keys
             continue;
         }
         // Set the value for all matched keys
         $params[$key] = $value;
         //<---
         // added by Yuna
         if (is_array($this->_retain) and in_array($key, $this->_retain) && $value != '') {
             // Value should be retained; add it to the _uri_defaults
             $this->_uri_defaults[$key] = $value;
         }
         //-->
     }
     foreach ($this->_defaults as $key => $value) {
         if (!isset($params[$key]) or $params[$key] === '') {
             // Set default values for any key that was not matched
             $params[$key] = $value;
         }
     }
     if (!empty($params['controller'])) {
         // PSR-0: Replace underscores with spaces, run ucwords, then replace underscore
         $params['controller'] = str_replace(' ', '_', ucwords(str_replace('_', ' ', $params['controller'])));
     }
     if (!empty($params['directory'])) {
         // PSR-0: Replace underscores with spaces, run ucwords, then replace underscore
         $params['directory'] = str_replace(' ', '_', ucwords(str_replace('_', ' ', $params['directory'])));
     }
     if ($this->_filters) {
         foreach ($this->_filters as $callback) {
             // Execute the filter giving it the route, params, and request
             $return = call_user_func($callback, $this, $params, $request);
             if ($return === FALSE) {
                 // Filter has aborted the match
                 return FALSE;
             } elseif (is_array($return)) {
                 // Filter has modified the parameters
                 $params = $return;
             }
         }
     }
     return $params;
 }
开发者ID:yubinchen18,项目名称:A-basic-website-project-for-a-company-using-the-MVC-pattern-in-Kohana-framework,代码行数:71,代码来源:Route.php

示例14: open

 /**
  * Open a HTML form.
  *
  * @param  string  $action
  * @param  string  $method
  * @param  array   $attributes
  * @param  bool    $https
  * @return string
  */
 public static function open($action = null, $method = 'POST', $attributes = array(), $https = false)
 {
     $attributes['action'] = HTML::entities(URL::to(is_null($action) ? Request::uri() : $action, $https));
     // PUT and DELETE methods are spoofed using a hidden field containing the request method.
     // Since, HTML does not support PUT and DELETE on forms, we will use POST.
     $attributes['method'] = ($method == 'PUT' or $method == 'DELETE') ? 'POST' : $method;
     if (!array_key_exists('accept-charset', $attributes)) {
         $attributes['accept-charset'] = Config::get('application.encoding');
     }
     $html = '<form' . HTML::attributes($attributes) . '>';
     if ($method == 'PUT' or $method == 'DELETE') {
         $html .= PHP_EOL . static::input('hidden', 'REQUEST_METHOD', $method);
     }
     return $html . PHP_EOL;
 }
开发者ID:hpaul,项目名称:Google-short,代码行数:24,代码来源:form.php

示例15: extend

 public static function extend($page)
 {
     if (is_array($page)) {
         $pages = array();
         foreach ($page as $itm) {
             $pages[] = static::extend($itm);
         }
         return $pages;
     }
     if (is_object($page)) {
         $uri = Request::uri();
         $page->url = Url::make($page->slug);
         $page->active = strlen($uri) ? strpos($uri, $page->slug) !== false : $page->slug === 'posts';
         return $page;
     }
     return false;
 }
开发者ID:rubenvincenten,项目名称:anchor-site,代码行数:17,代码来源:pages.php


注:本文中的Request::uri方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。