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


PHP Uri::getScheme方法代码示例

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


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

示例1: register

 public function register(Container $pimple)
 {
     // File extensions used to determine whether a URI points to an asset
     // or an HTML file.
     $pimple['html_extensions'] = static::$html_extensions;
     $pimple['asset_extensions'] = static::$asset_extensions;
     // Matches any URI we think points to an HTML page.
     $pimple['matcher.html'] = function () use($pimple) {
         return Matcher::all()->pathExtensionIs($pimple['html_extensions']);
     };
     // Matches any URI we think points to an asset file.
     $pimple['matcher.asset'] = function () use($pimple) {
         return Matcher::all()->pathExtensionIs($pimple['asset_extensions']);
     };
     // Matches any URI that is considered "in scope."
     $pimple['matcher.internal'] = function () use($pimple) {
         $uri = new Uri($pimple['base_url']);
         return Matcher::all()->schemeIs($uri->getScheme())->hostIs($uri->getHost())->pathMatches('~^' . preg_quote($uri->getPath(), '~') . '~');
     };
     // Matches any URI that is both internal and HTML.
     $pimple['matcher.internal_html'] = function () use($pimple) {
         return Matcher::all()->add($pimple['matcher.internal'])->add($pimple['matcher.html']);
     };
     // Matches any URI that is both internal and an asset.
     $pimple['matcher.internal_asset'] = function () use($pimple) {
         return Matcher::all()->add($pimple['matcher.internal'])->add($pimple['matcher.asset']);
     };
 }
开发者ID:LastCallMedia,项目名称:Crawler,代码行数:28,代码来源:MatcherServiceProvider.php

示例2: withBaseUri

 /**
  * @param string|UriInterface $baseUri
  * @return ApiUri
  * @throws \InvalidArgumentException
  */
 public function withBaseUri($baseUri)
 {
     if (empty($baseUri)) {
         throw new \InvalidArgumentException('You must provide a non-empty string or PSR-7 UserInterface');
     } elseif (is_string($baseUri)) {
         $baseUri = new Psr7\Uri($baseUri);
     } elseif (!$baseUri instanceof UriInterface) {
         throw new \InvalidArgumentException('Invalid format provided; should either be a string or PSR-7 UriInterface');
     }
     if (!in_array($baseUri->getScheme(), ['http', 'https'])) {
         throw new \InvalidArgumentException('Only http & https schemes are allowed');
     }
     // always store the base URI with a final /
     if (!preg_match('{/$}', $baseUri->getPath())) {
         $baseUri = $baseUri->withPath($baseUri->getPath() . '/');
     }
     /** @var ApiUri $new */
     if ('' === (string) $this) {
         $new = new static($baseUri);
     } else {
         $new = clone $this;
     }
     $new->baseUri = $baseUri;
     return $new;
 }
开发者ID:redefining,项目名称:rest-api-client,代码行数:30,代码来源:ApiUri.php

示例3: testParsesProvidedUrl

 public function testParsesProvidedUrl()
 {
     $uri = new Uri('https://michael:test@test.com:443/path/123?q=abc#test');
     // Standard port 443 for https gets ignored.
     $this->assertEquals('https://michael:test@test.com/path/123?q=abc#test', (string) $uri);
     $this->assertEquals('test', $uri->getFragment());
     $this->assertEquals('test.com', $uri->getHost());
     $this->assertEquals('/path/123', $uri->getPath());
     $this->assertEquals(null, $uri->getPort());
     $this->assertEquals('q=abc', $uri->getQuery());
     $this->assertEquals('https', $uri->getScheme());
     $this->assertEquals('michael:test', $uri->getUserInfo());
 }
开发者ID:shomimn,项目名称:builder,代码行数:13,代码来源:UriTest.php

示例4: request

 protected function request($method, $url, $params = [], $headers = [])
 {
     $jar = $this->cache->has($this->tabName) ? $this->cache->get($this->tabName) : new CookieJar();
     $url = new Uri($url);
     $headers = array_merge(['Content-Type' => 'application/x-www-form-urlencoded; charset=UTF-8', 'User-Agent' => 'Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/44.0.2403.155 Safari/537.36', 'Host' => $url->getHost(), 'Origin' => $url->getScheme() . "://" . $url->getHost() . "/"], $headers);
     $stack = HandlerStack::create();
     $stack->push(Middleware::mapRequest(function (RequestInterface $request) {
         $URI = $request->getUri();
         $this->baseUri = $URI->__toString();
         return $request->withUri($URI);
     }));
     $client = new Client(["cookies" => $jar, 'handler' => $stack, 'verify' => __DIR__ . '/../cacert.pem']);
     $request = new GuzzleHttpRequest($method, $url, $headers, http_build_query($params));
     $this->response = $client->send($request, ['timeout' => 120]);
     $this->cache->put($this->tabName, $jar, 24 * 60);
 }
开发者ID:ifgroup,项目名称:browser,代码行数:16,代码来源:Browser.php

示例5: assertUriEquals

 protected function assertUriEquals($expectedUri, $actualUri)
 {
     if (is_string($expectedUri)) {
         $expectedUri = new Psr7\Uri($expectedUri);
     }
     if (is_string($actualUri)) {
         $actualUri = new Psr7\Uri($actualUri);
     }
     $this->assertEquals($expectedUri->getScheme(), $actualUri->getScheme());
     $this->assertEquals($expectedUri->getPort(), $actualUri->getPort());
     $this->assertEquals($expectedUri->getHost(), $actualUri->getHost());
     $this->assertEquals($expectedUri->getPath(), $actualUri->getPath());
     $expectedQueryParts = Psr7\parse_query($expectedUri->getQuery());
     $actualQueryParts = Psr7\parse_query($actualUri->getQuery());
     $this->assertEquals($expectedQueryParts, $actualQueryParts);
 }
开发者ID:redefining,项目名称:rest-api-client,代码行数:16,代码来源:UriAssertions.php

示例6: baseString

 /**
  * Generate a base string for a HMAC-SHA1 signature
  * based on the given a url, method, and any parameters.
  *
  * @param Url    $url
  * @param string $method
  * @param array  $parameters
  *
  * @return string
  */
 protected function baseString(Uri $url, $method = 'POST', array $parameters = array())
 {
     $baseString = rawurlencode($method) . '&';
     $schemeHostPath = Uri::fromParts(array('scheme' => $url->getScheme(), 'host' => $url->getHost(), 'path' => $url->getPath()));
     $baseString .= rawurlencode($schemeHostPath) . '&';
     $data = array();
     parse_str($url->getQuery(), $query);
     $data = array_merge($query, $parameters);
     // normalize data key/values
     array_walk_recursive($data, function (&$key, &$value) {
         $key = rawurlencode(rawurldecode($key));
         $value = rawurlencode(rawurldecode($value));
     });
     ksort($data);
     $baseString .= $this->queryStringFromData($data);
     return $baseString;
 }
开发者ID:dukt,项目名称:craft-oauth,代码行数:27,代码来源:HmacSha1Signature.php

示例7: __construct

 public function __construct(Options $options, OutputInterface $ouput)
 {
     $timeout = $options->getTimeout();
     $client = new ClientGuzzle(['timeout' => $timeout]);
     $url = $options->getUrl();
     $response = $client->get($url);
     if ($response->getStatusCode() != 200) {
         throw new RuntimeException(sprintf('Cannot access this url: "%s"', $url));
     }
     $uri = new Uri($url);
     $baseUri = $uri->getScheme() . '://' . $uri->getHost();
     if (!empty($uri->getPort())) {
         $baseUri .= ':' . $uri->getPort();
     }
     $options->setBaseUri($baseUri);
     $this->options = $options;
     $this->output = $ouput;
 }
开发者ID:tmquang6805,项目名称:scrapimage,代码行数:18,代码来源:Client.php

示例8: generateUri

 private function generateUri()
 {
     $uri = new Uri($this->client->getEndpoint());
     if ($uri->getScheme() === 'https' && strpos($this->bucket, '.') !== false) {
         // Use path-style URLs
         $uri = $uri->withPath($this->bucket);
     } else {
         // Use virtual-style URLs
         $uri = $uri->withHost($this->bucket . '.' . $uri->getHost());
     }
     return (string) $uri;
 }
开发者ID:Afrozaar,项目名称:wp-api-v2-afrozaar-extras,代码行数:12,代码来源:PostObject.php

示例9: testDefaultReturnValuesOfGetters

 public function testDefaultReturnValuesOfGetters()
 {
     $uri = new Uri();
     $this->assertSame('', $uri->getScheme());
     $this->assertSame('', $uri->getAuthority());
     $this->assertSame('', $uri->getUserInfo());
     $this->assertSame('', $uri->getHost());
     $this->assertNull($uri->getPort());
     $this->assertSame('', $uri->getPath());
     $this->assertSame('', $uri->getQuery());
     $this->assertSame('', $uri->getFragment());
 }
开发者ID:nystudio107,项目名称:instantanalytics,代码行数:12,代码来源:UriTest.php


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