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


PHP Url::buildUrl方法代码示例

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


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

示例1: fromMessage

 /**
  * Create a request or response object from an HTTP message string
  *
  * @param string $message Message to parse
  *
  * @return RequestInterface|ResponseInterface
  * @throws \InvalidArgumentException if unable to parse a message
  */
 public function fromMessage($message)
 {
     static $parser;
     if (!$parser) {
         $parser = new MessageParser();
     }
     // Parse a response
     if (strtoupper(substr($message, 0, 4)) == 'HTTP') {
         $data = $parser->parseResponse($message);
         return $this->createResponse($data['code'], $data['headers'], $data['body'] === '' ? null : $data['body'], $data);
     }
     // Parse a request
     if (!($data = $parser->parseRequest($message))) {
         throw new \InvalidArgumentException('Unable to parse request');
     }
     return $this->createRequest($data['method'], Url::buildUrl($data['request_url']), ['headers' => $data['headers'], 'body' => $data['body'] === '' ? null : $data['body'], 'config' => ['protocol_version' => $data['protocol_version']]]);
 }
开发者ID:hilmysyarif,项目名称:sic,代码行数:25,代码来源:MessageFactory.php

示例2: getAbsoluteUri

 public function getAbsoluteUri($uri)
 {
     $build = parse_url($this->baseUri);
     $uriparts = parse_url(preg_replace('~^/+(?=/)~', '', $uri));
     if ($build === false) {
         throw new \Codeception\Exception\TestRuntime("URL '{$this->baseUri}' is malformed");
     } elseif ($uriparts === false) {
         throw new \Codeception\Exception\TestRuntime("URI '{$uri}' is malformed");
     }
     foreach ($uriparts as $part => $value) {
         if ($part === 'path' && strpos($value, '/') !== 0 && !empty($build[$part])) {
             $build[$part] = rtrim($build[$part], '/') . '/' . $value;
         } else {
             $build[$part] = $value;
         }
     }
     return \GuzzleHttp\Url::buildUrl($build);
 }
开发者ID:alexanderkuz,项目名称:test-yii2,代码行数:18,代码来源:Guzzle.php

示例3: getAbsoluteUrlFor

 /**
  * Returns an absolute URL for the passed URI with the current URL
  * as the base path.
  *
  * @param string $uri the absolute or relative URI
  * @return string the absolute URL
  * @throws Codeception\Exception\TestRuntime if either the current
  *         URL or the passed URI can't be parsed
  */
 protected function getAbsoluteUrlFor($uri)
 {
     $currentUrl = $this->client->getHistory()->current()->getUri();
     if (empty($uri) || $uri === '#') {
         return $currentUrl;
     }
     $build = parse_url($currentUrl);
     $uriParts = parse_url($uri);
     if ($build === false) {
         throw new TestRuntime("URL '{$currentUrl}' is malformed");
     } elseif ($uriParts === false) {
         throw new TestRuntime("URI '{$uri}' is malformed");
     }
     $abs = $this->mergeUrls($build, $uriParts);
     return \GuzzleHttp\Url::buildUrl($abs);
 }
开发者ID:alexanderkuz,项目名称:test-yii2,代码行数:25,代码来源:InnerBrowser.php

示例4: testAddsQueryIfPresent

 public function testAddsQueryIfPresent()
 {
     $this->assertEquals('?foo=bar', Url::buildUrl(array('query' => 'foo=bar')));
 }
开发者ID:JREAMLU,项目名称:timeline,代码行数:4,代码来源:UrlTest.php

示例5: getAbsoluteUri

 public function getAbsoluteUri($uri)
 {
     if ($uri && 0 !== strpos($uri, 'http') && $uri[0] !== '/' && $this->redirect) {
         $currentUri = $this->history->current()->getUri();
         $path = parse_url($currentUri, PHP_URL_PATH);
         if ('/' !== substr($path, -1)) {
             $path = substr($path, 0, strrpos($path, '/') + 1);
         }
         $uri = $path . $uri;
     }
     $build = parse_url($this->baseUri);
     $uriParts = parse_url(preg_replace('~^/+(?=/)~', '', $uri));
     if ($build === false) {
         throw new TestRuntimeException("URL '{$this->baseUri}' is malformed");
     } elseif ($uriParts === false) {
         throw new TestRuntimeException("URI '{$uri}' is malformed");
     }
     foreach ($uriParts as $part => $value) {
         if ($part === 'path' && strpos($value, '/') !== 0 && !empty($build[$part])) {
             $build[$part] = rtrim($build[$part], '/') . '/' . $value;
         } else {
             $build[$part] = $value;
         }
     }
     return \GuzzleHttp\Url::buildUrl($build);
 }
开发者ID:nhemnhem,项目名称:learning_test,代码行数:26,代码来源:Guzzle.php

示例6: getFormUrl

 /**
  * @param \Symfony\Component\DomCrawler\Crawler $form
  *
  * @return string
  */
 protected function getFormUrl($form)
 {
     $action = $form->attr('action');
     $currentUrl = $this->client->getHistory()->current()->getUri();
     if (empty($action) || $action === '#') {
         return $currentUrl;
     }
     $build = parse_url($currentUrl);
     if ($build === false) {
         throw new TestRuntime("URL '{$currentUrl}' is malformed");
     }
     $uriParts = parse_url($action);
     if ($uriParts === false) {
         throw new TestRuntime("URI '{$action}' is malformed");
     }
     foreach ($uriParts as $part => $value) {
         if ($part === 'path' && strpos($value, '/') !== 0 && !empty($build[$part])) {
             // if it ends with a slash, relative paths are below it
             if (preg_match('~/$~', $build[$part])) {
                 $build[$part] = $build[$part] . $value;
                 continue;
             }
             $build[$part] = dirname($build[$part]) . '/' . $value;
             continue;
         }
         $build[$part] = $value;
     }
     return \GuzzleHttp\Url::buildUrl($build);
 }
开发者ID:samuelmoncarey,项目名称:codeception,代码行数:34,代码来源:InnerBrowser.php

示例7: transformToUploadUrl

 private function transformToUploadUrl()
 {
     $parts = parse_url($this->request->getUrl());
     if (!isset($parts['path'])) {
         $parts['path'] = '';
     }
     $parts['path'] = '/upload' . $parts['path'];
     $url = Url::fromString(Url::buildUrl($parts));
     $this->request->setUrl($url);
 }
开发者ID:OlivierBarbier,项目名称:google-api-php-client,代码行数:10,代码来源:MediaFileUpload.php

示例8: setUrlHelper

 /**
  * Set base parameters of homepage url.
  *
  * @param string $homepage satis repository url
  */
 private function setUrlHelper($homepage)
 {
     $parsedUrl = Url::fromString($homepage)->getParts();
     if (isset($parsedUrl['user']) && isset($parsedUrl['pass'])) {
         $this->credentials = array('auth' => array($parsedUrl['user'], $parsedUrl['pass']));
     }
     if (isset($parsedUrl['path'])) {
         $this->basePath = $parsedUrl['path'];
         $this->basePath .= substr($this->basePath, -1) == '/' ? '' : '/';
     }
     $this->baseUrl = Url::buildUrl(array('scheme' => $parsedUrl['scheme'], 'host' => $parsedUrl['host'], 'port' => $parsedUrl['port']));
     return $this;
 }
开发者ID:holisticagency,项目名称:satis-http-client,代码行数:18,代码来源:SatisHttpClient.php

示例9: coerceUri

 private function coerceUri($uri)
 {
     if (is_null($uri)) {
         return null;
     } else {
         if (is_string($uri)) {
             return Url::fromString($uri);
         } else {
             if (is_array($uri)) {
                 return Url::buildUrl($uri);
             } else {
                 if (get_class($uri) == 'GuzzleHttp\\Url') {
                     return $uri;
                 } else {
                     throw new \InvalidArgumentException('unexpected type for a uri: ' . get_class($uri));
                 }
             }
         }
     }
 }
开发者ID:dwsupplee,项目名称:google-auth-library-php,代码行数:20,代码来源:OAuth2.php

示例10: amOnPage

 public function amOnPage($page)
 {
     $build = parse_url($this->config['url']);
     $uriparts = parse_url($page);
     if ($build === false) {
         throw new \Codeception\Exception\TestRuntime("URL '{$this->config['url']}' is malformed");
     } elseif ($uriparts === false) {
         throw new \Codeception\Exception\TestRuntime("URI '{$page}' is malformed");
     }
     foreach ($uriparts as $part => $value) {
         if ($part === 'path' && !empty($build[$part])) {
             $build[$part] = rtrim($build[$part], '/') . '/' . ltrim($value, '/');
         } else {
             $build[$part] = $value;
         }
     }
     $this->webDriver->get(\GuzzleHttp\Url::buildUrl($build));
 }
开发者ID:kansey,项目名称:yii2albom,代码行数:18,代码来源:WebDriver.php


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