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


PHP Uri::createFromString方法代码示例

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


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

示例1: requestFactory

 /**
  * @param $method
  * @param $path
  * @param $body
  * @param $options
  * @return Request
  */
 protected function requestFactory($method, $path, $body = [], $options = [])
 {
     $uri = Uri::createFromString($path);
     $headers = new Headers();
     $cookies = [];
     $_POST['_METHOD'] = $method;
     if (strtolower($method) != 'get' && is_array($body)) {
         foreach ($body as $key => $value) {
             $_POST[$key] = $value;
         }
     }
     $envMethod = 'POST';
     if (strtolower($method) == 'get') {
         $envMethod = 'GET';
     }
     $env = Environment::mock(['REQUEST_URI' => $path, 'REQUEST_METHOD' => $envMethod, 'HTTP_CONTENT_TYPE' => 'multipart/form-data; boundary=---foo']);
     $serverParams = $env->all();
     $body = $this->buildBody($body);
     //echo $body->getContents();
     // @todo
     // $request = new Request($method, $uri, $headers, $cookies, $serverParams, $body, []);
     $request = Request::createFromEnvironment($env);
     unset($_POST);
     return $request;
 }
开发者ID:SharkIng,项目名称:ss-panel,代码行数:32,代码来源:TestCase.php

示例2: testAbsoluteUrlGetsRouteAndAppendsPortWhenNotStandard

 public function testAbsoluteUrlGetsRouteAndAppendsPortWhenNotStandard()
 {
     $uri = SlimUri::createFromString('http://host:8443/path/page?query=1');
     $this->router->shouldReceive('relativePathFor')->with('route.name', ['param1' => '1'], [])->andReturn('/test-route-page');
     $url = new URI($this->router);
     $actual = $url->absoluteURIFor($uri, 'route.name', ['param1' => '1']);
     $this->assertSame('http://host:8443/test-route-page', $actual);
 }
开发者ID:quickenloans-mcp,项目名称:mcp-panthor,代码行数:8,代码来源:URITest.php

示例3: requestFactory

 public function requestFactory()
 {
     $uri = Uri::createFromString('https://example.com:443/foo/bar?abc=123');
     $headers = new Headers();
     $cookies = [];
     $serverParams = [];
     $body = new Body(fopen('php://temp', 'r+'));
     return new Request('GET', $uri, $headers, $cookies, $serverParams, $body);
 }
开发者ID:aodkrisda,项目名称:slim-3-framework-app,代码行数:9,代码来源:CacheTest.php

示例4: createUri

 /**
  * {@inheritdoc}
  */
 public function createUri($uri)
 {
     if ($uri instanceof UriInterface) {
         return $uri;
     }
     if (is_string($uri)) {
         return Uri::createFromString($uri);
     }
     throw new \InvalidArgumentException('URI must be a string or UriInterface');
 }
开发者ID:php-http,项目名称:message,代码行数:13,代码来源:SlimUriFactory.php

示例5: makeRequest

 /**
  * @param $method
  * @param string $url
  *
  * @return Request
  */
 public function makeRequest($method, $url = '/')
 {
     $env = Environment::mock();
     $uri = Uri::createFromString('http://example.com' . $url);
     $headers = Headers::createFromEnvironment($env);
     $serverParams = $env->all();
     $body = new RequestBody();
     $uploadedFiles = UploadedFile::createFromEnvironment($env);
     $request = new Request($method, $uri, $headers, [], $serverParams, $body, $uploadedFiles);
     return $request;
 }
开发者ID:ChrisBrenton,项目名称:recipes,代码行数:17,代码来源:RequestFactory.php

示例6: setUp

 /**
  * Run before each test
  */
 public function setUp()
 {
     $uri = \Slim\Http\Uri::createFromString('https://example.com:443/foo/bar?abc=123');
     $headers = new \Slim\Http\Headers();
     $cookies = new \Slim\Collection();
     $env = \Slim\Http\Environment::mock();
     $serverParams = new \Slim\Collection($env->all());
     $body = new \Slim\Http\Body(fopen('php://temp', 'r+'));
     $this->request = new \Slim\Http\Request('GET', $uri, $headers, $cookies, $serverParams, $body);
     $this->response = new \Slim\Http\Response();
 }
开发者ID:elbajuri,项目名称:ketupat,代码行数:14,代码来源:CsrfTest.php

示例7: requestFactory

 public function requestFactory($acceptType = 'application/json')
 {
     $env = Environment::mock(['HTTP_ACCEPT' => $acceptType]);
     $uri = Uri::createFromString('https://example.com:443/foo/bar?abc=123');
     $headers = Headers::createFromEnvironment($env);
     $serverParams = $env->all();
     $body = new RequestBody();
     $uploadedFiles = UploadedFile::createFromEnvironment($env);
     $request = new Request('GET', $uri, $headers, [], $serverParams, $body, $uploadedFiles);
     return $request;
 }
开发者ID:slimphp-api,项目名称:slim-json,代码行数:11,代码来源:JsonTest.php

示例8: setUp

 /**
  * Run before each test.
  */
 public function setUp()
 {
     $uri = Uri::createFromString('https://example.com:443/foo/bar');
     $headers = new Headers();
     $cookies = [];
     $env = Environment::mock();
     $serverParams = $env->all();
     $body = new Body(fopen('php://temp', 'r+'));
     $this->request = new Request('GET', $uri, $headers, $cookies, $serverParams, $body);
     $this->response = new Response();
 }
开发者ID:davidepastore,项目名称:slim-config,代码行数:14,代码来源:ConfigTest.php

示例9: requestFactory

 public function requestFactory($requestUrl)
 {
     $uri = Uri::createFromString($requestUrl);
     $headers = new Headers();
     $cookies = [];
     $env = Slim\Http\Environment::mock();
     $serverParams = $env->all();
     $body = new Body(fopen('php://temp', 'r+'));
     $request = new Request('GET', $uri, $headers, $cookies, $serverParams, $body);
     return $request;
 }
开发者ID:mrmoneyc,项目名称:slim-mvc-skeleton,代码行数:11,代码来源:bootstrap.php

示例10: requestFactory

 public function requestFactory($queryString = '')
 {
     $env = Environment::mock();
     $uri = Uri::createFromString('https://example.com:443/foo/bar' . $queryString);
     $headers = Headers::createFromEnvironment($env);
     $cookies = ['user' => 'john', 'id' => '123'];
     $serverParams = $env->all();
     $body = new RequestBody();
     $uploadedFiles = UploadedFile::createFromEnvironment($env);
     $request = new Request('GET', $uri, $headers, $cookies, $serverParams, $body, $uploadedFiles);
     return $request;
 }
开发者ID:geggleto,项目名称:sessionmiddleware,代码行数:12,代码来源:SessionMiddlewareTest.php

示例11: requestFactory

 private function requestFactory($endpoint)
 {
     // Request
     $uri = Uri::createFromString('https://example.com:443/' . $endpoint);
     $headers = new Headers();
     $cookies = [];
     $serverParams = [];
     $body = new Body(fopen('php://temp', 'r+'));
     $request = new Request('GET', $uri, $headers, $cookies, $serverParams, $body);
     $request = $request->withAttribute('route', new Route(['get'], '/' . $endpoint, 'CallableFunction'));
     return $request;
 }
开发者ID:kanellov,项目名称:slim-acl,代码行数:12,代码来源:GuardTest.php

示例12: makeRequest

 /**
  * @param string $method
  * @param string $uri
  * @return Request
  */
 public function makeRequest($method = 'GET', $uri = '')
 {
     $env = Environment::mock([]);
     $uri = Uri::createFromString($uri);
     $headers = Headers::createFromEnvironment($env);
     $cookies = [];
     $serverParams = $env->all();
     $body = new RequestBody();
     $uploadedFiles = UploadedFile::createFromEnvironment($env);
     $request = new Request($method, $uri, $headers, $cookies, $serverParams, $body, $uploadedFiles);
     $request = $request->withHeader("Content-Type", "application/x-www-form-urlencoded");
     return $request;
 }
开发者ID:geggleto,项目名称:slimgateway,代码行数:18,代码来源:RequestFactory.php

示例13: setUpXmlPost

 /**
  * Setup for the XML POST requests.
  *
  * @param string $xml The XML to use to mock the body of the request.
  */
 public function setUpXmlPost($xml)
 {
     $uri = Uri::createFromString('https://example.com:443/foo');
     $headers = new Headers();
     $headers->set('Content-Type', 'application/xml;charset=utf8');
     $cookies = [];
     $env = Environment::mock(['SCRIPT_NAME' => '/index.php', 'REQUEST_URI' => '/foo', 'REQUEST_METHOD' => 'POST']);
     $serverParams = $env->all();
     $body = new RequestBody();
     $body->write($xml);
     $this->request = new Request('POST', $uri, $headers, $cookies, $serverParams, $body);
     $this->response = new Response();
 }
开发者ID:DavidePastore,项目名称:Slim-Validation,代码行数:18,代码来源:ValidationTest.php

示例14: runPost

 /**
  * run application with POST method.
  * adds C.S.R.F. token if $post is set.
  *
  * @param string $path
  * @param array  $post
  */
 protected function runPost($path = '', $post = [])
 {
     if (!empty($post)) {
         // add csrf tokens.
         $key = 'unit-csrf';
         $val = 'unit-csrf-value';
         $_SESSION['csrf'][$key] = $val;
         $post['csrf_name'] = $key;
         $post['csrf_value'] = $val;
     }
     $uri = Uri::createFromString($this->root_url . $path);
     $this->runApp('POST', $uri, $post);
 }
开发者ID:asaokamei,项目名称:slim-tuum,代码行数:20,代码来源:UnitTestsAppTrait.php

示例15: setUp

 /**
  * Run before each test.
  */
 public function setUp()
 {
     parent::setUp();
     $uri = Uri::createFromString('https://example.com:443/foo/bar?abc=123');
     $this->request = new Request('GET', $uri, new Headers(), [], Environment::mock()->all(), new Body(fopen('php://temp', 'r+')));
     $this->response = new Response();
     // Prepare container and populate it with Slim services that are needed for further tests
     $this->addToContainer('callableResolver', function ($c) {
         return new CallableResolver($c);
     });
     $this->addToContainer('foundHandler', function ($c) {
         return new RequestResponse();
     });
 }
开发者ID:activecollab,项目名称:bootstrap,代码行数:17,代码来源:RequestResponseTestCase.php


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