當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Request::getUrl方法代碼示例

本文整理匯總了PHP中Request::getUrl方法的典型用法代碼示例。如果您正苦於以下問題:PHP Request::getUrl方法的具體用法?PHP Request::getUrl怎麽用?PHP Request::getUrl使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Request的用法示例。


在下文中一共展示了Request::getUrl方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: request

 /**
  * @param Request $request
  * @return RawResponse
  * @throws \Exception
  */
 public function request(Request $request)
 {
     $res = $this->client->request('GET', $request->getUrl());
     if ($res->getStatusCode() == 200) {
         return new RawResponse((string) $res->getBody());
     }
     throw new \Exception('Error code', $res->getStatusCode());
 }
開發者ID:mglaman,項目名稱:drupalorg-cli,代碼行數:13,代碼來源:Client.php

示例2: cleanupCheck

 /**
  * Cleanup the cookie support check
  */
 public function cleanupCheck()
 {
     if ($this->request->getUrl()->hasParam('_checkCookie') && isset($_COOKIE[self::CHECK_COOKIE])) {
         $requestUri = $this->request->getUrl()->without('_checkCookie');
         $this->request->getResponse()->redirectAndExit($requestUri);
     }
 }
開發者ID:trigoesrodrigo,項目名稱:icingaweb2,代碼行數:10,代碼來源:Cookie.php

示例3: initCurl

 private function initCurl()
 {
     $this->curl = curl_init($this->request->getUrl());
     foreach ($this->request->getOptions() as $option) {
         curl_setopt($this->curl, $option[0], $option[1]);
     }
     $this->curlResponse = curl_exec($this->curl);
 }
開發者ID:phpwrapper,項目名稱:curl,代碼行數:8,代碼來源:Response.php

示例4: match

 /**
  * Matches Request to one of defined routes
  *
  * @param Request $request
  * @return array
  * @throws NoRouteFound
  */
 public function match(Request $request)
 {
     $method = $request->getMethod();
     if (isset($this->routes[$method])) {
         foreach ((array) $this->routes[$method] as $routePattern => $routeSettings) {
             if ($this->matchRoute($request->getUrl(), $routePattern, $routeSettings) === TRUE) {
                 return $routeSettings;
             }
         }
     }
     http_response_code(404);
     throw new NoRouteFound('No routed found for method "' . $method . '" and URL "' . $request->getUrl() . '"');
 }
開發者ID:JanPetr,項目名稱:AlgoliaTestAppStore,代碼行數:20,代碼來源:Router.php

示例5: call

 /**
  * @param Request $request
  * @return Response
  */
 public function call(Request $request)
 {
     // Create cURL
     $ch = curl_init();
     // Set-up URL
     curl_setopt($ch, CURLOPT_URL, $request->getUrl());
     // Set-up headers
     $headers = $request->getHeaders();
     array_walk($headers, function (&$item, $key) {
         $item = "{$key}: {$item}";
     });
     curl_setopt($ch, CURLOPT_HTTPHEADER, array_values($headers));
     // Set-up others
     curl_setopt_array($ch, $request->getOpts());
     // Receive result
     $result = curl_exec($ch);
     // Parse response
     $response = new Response();
     if ($result === FALSE) {
         $response->setError(curl_strerror(curl_errno($ch)));
         $response->setData(FALSE);
         $response->setCode(curl_errno($ch));
         $response->setHeaders(curl_getinfo($ch));
     } else {
         $response->setData(json_decode($result));
         $response->setCode(curl_getinfo($ch, CURLINFO_HTTP_CODE));
         $response->setHeaders(curl_getinfo($ch));
     }
     // Close cURL
     curl_close($ch);
     return $response;
 }
開發者ID:r01261,項目名稱:GopayInline,代碼行數:36,代碼來源:Curl.php

示例6: testConstruct

 function testConstruct()
 {
     $request = new Request('GET', '/foo', ['User-Agent' => 'Evert']);
     $this->assertEquals('GET', $request->getMethod());
     $this->assertEquals('/foo', $request->getUrl());
     $this->assertEquals(['User-Agent' => ['Evert']], $request->getHeaders());
 }
開發者ID:sebbie42,項目名稱:casebox,代碼行數:7,代碼來源:RequestTest.php

示例7: testGetUrlFormatsAUrl

 public function testGetUrlFormatsAUrl()
 {
     $request = new Request();
     $request->setHost('http://example.com');
     $request->setResource('/resource/123');
     $this->assertEquals($request->getUrl(), 'http://example.com/resource/123');
 }
開發者ID:philip,項目名稱:Buzz,代碼行數:7,代碼來源:RequestTest.php

示例8: execute

 public function execute(Request $request)
 {
     $ch = curl_init();
     curl_setopt($ch, CURLOPT_URL, $request->getUrl());
     curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
     curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
     curl_setopt($ch, CURLOPT_HTTPHEADER, array('Expect:'));
     $username = $request->getUsername();
     $password = $request->getPassword();
     if ($username && $password) {
         curl_setopt($ch, CURLOPT_USERPWD, $username . ':' . $password);
     }
     switch ($request->getMethod()) {
         case self::POST:
         case self::PUT:
             curl_setopt($ch, CURLOPT_POST, 1);
             curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($request->getParameters()));
             break;
         case self::DELETE:
             curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'DELETE');
             break;
         case self::GET:
         default:
             break;
     }
     $result = curl_exec($ch);
     if (!$result) {
         $errorNumber = curl_errno($ch);
         $error = curl_error($ch);
         curl_close($ch);
         throw new \Exception($errorNumer . ': ' . $error);
     }
     curl_close($ch);
     return $request->getResponseTransformerImpl()->transform($result);
 }
開發者ID:ner0tic,項目名稱:rest,代碼行數:35,代碼來源:Client.php

示例9: redirect

 /**
  * @param $destination
  */
 public function redirect($destination)
 {
     if (!isset($_SESSION)) {
         session_start();
     }
     $_SESSION['referrer'] = Request::getUrl();
     header('Location: ' . $destination, true);
     exit;
 }
開發者ID:arkuuu,項目名稱:publin,代碼行數:12,代碼來源:Controller.php

示例10: handle

 public function handle(Request $req, Response $res) : Response
 {
     if ($this->startTime) {
         $endTime = microtime(true);
         $message = date(\DateTime::ATOM, $this->startTime) . ' ' . $req->getUrl()->getFull() . ' ' . ($endTime - $this->startTime);
         file_put_contents($this->logfile, $message, \FILE_APPEND | \LOCK_EX);
     } else {
         $this->startTime = microtime(true);
     }
 }
開發者ID:inad9300,項目名稱:bed.php,代碼行數:10,代碼來源:TimeLogger.php

示例11: construct

 /**
  * Verify basic functionality of the request object.
  *
  * @test
  * @covers ::__construct
  * @covers ::getUrl
  * @covers ::getBody
  * @covers ::getMethod
  * @covers ::getHeaders
  *
  * @return void
  */
 public function construct()
 {
     $url = 'a url';
     $method = 'a method';
     $body = ['some' => 'data'];
     $headers = ['key' => 'value'];
     $request = new Request($url, $method, $headers, $body);
     $this->assertSame($url, $request->getUrl());
     $this->assertSame($method, $request->getMethod());
     $this->assertSame($headers, $request->getHeaders());
     $this->assertSame($body, $request->getBody());
 }
開發者ID:chadicus,項目名稱:marvel-api-client,代碼行數:24,代碼來源:RequestTest.php

示例12: handle

 /**
  * Handle Request.
  *
  * Determines which router should be executed and hand over job to it
  *
  * @param Request $request
  *
  * @return Response
  */
 public function handle(Request $request)
 {
     $router = $this->findRouter($request->getUrl());
     if (is_null($router)) {
         return $this->getNotFoundResponse('Cannot found Controller');
     }
     /** @var Controller $controller */
     $controller = new $router['class']();
     $controller->setService('octrine', $this->configureOctrineService());
     $controller->setService('session', $this->configureSession());
     return call_user_func_array([$controller, $router['method']], [$request]);
 }
開發者ID:serkin,項目名稱:blog,代碼行數:21,代碼來源:Application.php

示例13: __construct

 public function __construct(\Request $request, \Http\ErrorResponse $response)
 {
     $vars = array();
     $vars['url'] = $request->getUrl();
     $vars['method'] = $request->getMethod();
     $vars['module'] = $request->getModule();
     $vars['code'] = $response->getCode();
     $vars['phrase'] = $response->getPhrase();
     $vars['backtrace'] = $response->getBacktrace();
     $vars['exception'] = $response->getException();
     $this->code = $vars['code'];
     parent::__construct($vars, PHPWS_SOURCE_DIR . 'Global/Templates/Http/HtmlError.html', false);
 }
開發者ID:HaldunA,項目名稱:phpwebsite,代碼行數:13,代碼來源:HtmlErrorView.php

示例14: parser

 /**
  * 解析路由規則表
  *+--------------
  * @param Void
  * @return Self
  */
 public function parser()
 {
     $url = $this->request->getUrl();
     if ($url) {
         //如果$uri不為空,遍曆路由規則表,將$uri與每條規則表進行正則匹配,直到找到相匹配的規則信息;否則拋出異常
         foreach ($this->routes as $key => $route) {
             if (empty($route)) {
                 continue;
             }
             if (preg_match($this->matchs($route), $url, $this->matchs)) {
                 $this->active = $key;
                 break;
             }
         }
     } else {
         //獲取默認路由規則,路由表最後一個
         $route = $this->routes[count($this->routes) - 1];
         if (isset($route[2])) {
             $this->matchs = $route[2];
         }
     }
     return $this;
 }
開發者ID:adawongframework,項目名稱:project,代碼行數:29,代碼來源:Route.php

示例15: passThrough

 public function passThrough(Request $request)
 {
     $params = $request->getParameters();
     if (array_key_exists('api_key', $params)) {
         throw new \ErrorException('Request contains parameter with a reserved name: \'api_key\'');
     }
     if (array_key_exists('api_sig', $params)) {
         throw new \ErrorException('Request contains parameter with a reserved name: \'api_sig\'');
     }
     $params['api_key'] = $this->consumerKey;
     $baseString = BaseString::compute($request->getMethod(), $request->getUrl(), $params);
     $signature = base64_encode(hash_hmac('sha1', $baseString, rawurlencode($this->consumerSecret), true));
     $request->setParameter('api_key', $this->consumerKey);
     $request->setParameter('api_sig', $signature);
 }
開發者ID:jonasvr,項目名稱:lockedornot,代碼行數:15,代碼來源:RequestSigningSession.php


注:本文中的Request::getUrl方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。