本文整理汇总了PHP中Zend\Diactoros\ServerRequestFactory::get方法的典型用法代码示例。如果您正苦于以下问题:PHP ServerRequestFactory::get方法的具体用法?PHP ServerRequestFactory::get怎么用?PHP ServerRequestFactory::get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Zend\Diactoros\ServerRequestFactory
的用法示例。
在下文中一共展示了ServerRequestFactory::get方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: fromGlobals
public static function fromGlobals(array $server = null, array $query = null, array $body = null, array $cookies = null, array $files = null)
{
$server = parent::normalizeServer($server);
$files = parent::normalizeFiles($files);
$headers = parent::marshalHeaders($server);
return new ServerRequest($server, $files, parent::marshalUriFromServer($server, $headers), parent::get('REQUEST_METHOD', $server, 'GET'), 'php://input', $headers, $cookies, $query, $body, self::marshalProtocolVersion($server));
}
示例2: createRequest
/**
* Creates a PSR-7 compatible request
*
* @param \TYPO3\Flow\Http\Request $nativeRequest Flow request object
* @param array $files List of uploaded files like in $_FILES
* @param array $query List of uploaded files like in $_GET
* @param array $post List of uploaded files like in $_POST
* @param array $cookies List of uploaded files like in $_COOKIES
* @param array $server List of uploaded files like in $_SERVER
* @return \Psr\Http\Message\ServerRequestInterface PSR-7 request object
*/
protected function createRequest(array $files, array $query, array $post, array $cookies, array $server)
{
if (!isset($server['HTTP_HOST'])) {
$server['HTTP_HOST'] = 'localhost';
}
$files = ServerRequestFactory::normalizeFiles($files);
$server = ServerRequestFactory::normalizeServer($server);
$headers = ServerRequestFactory::marshalHeaders($server);
$uri = ServerRequestFactory::marshalUriFromServer($server, $headers);
$method = ServerRequestFactory::get('REQUEST_METHOD', $server, 'GET');
return new ServerRequest($server, $files, $uri, $method, 'php://input', $headers, $cookies, $query, $post);
}
示例3: __construct
/**
* Sapi constructor.
*
* @param EmitterInterface $sapiEmitter
* @param array|null $server
* @param array|null $queryParams
* @param array|object|null $parsedBody
* @param array|null $cookies
* @param array|null $files
* @param string|resource|StreamInterface $messageBody
*
* @SuppressWarnings(PHPMD.StaticAccess)
* @SuppressWarnings(PHPMD.Superglobals)
*/
public function __construct(EmitterInterface $sapiEmitter, array $server = null, array $queryParams = null, array $parsedBody = null, array $cookies = null, array $files = null, $messageBody = 'php://input')
{
$this->sapiEmitter = $sapiEmitter;
// returns value if not null or $fallback otherwise
$get = function ($nullable, $fallback) {
return $nullable !== null ? $nullable : $fallback;
};
// Code below based on ServerRequestFactory::fromGlobals
$this->server = ServerRequestFactory::normalizeServer($get($server, $_SERVER));
$this->files = ServerRequestFactory::normalizeFiles($get($files, $_FILES));
$this->headers = ServerRequestFactory::marshalHeaders($this->server);
$this->uri = ServerRequestFactory::marshalUriFromServer($this->server, $this->headers);
$this->method = ServerRequestFactory::get('REQUEST_METHOD', $this->server, 'GET');
$this->cookies = $get($cookies, $_COOKIE);
$this->queryParams = $get($queryParams, $_GET);
$this->parsedBody = $get($parsedBody, $_POST);
$this->messageBody = $messageBody;
}
示例4: getServerRequest
/**
* {@inheritdoc}
*/
public function getServerRequest()
{
$query = $this->getQuery();
$post = $this->getPost();
$cookies = $this->getCookies();
$server = ServerRequestFactory::normalizeServer($this->params);
$headers = ServerRequestFactory::marshalHeaders($server);
$uri = ServerRequestFactory::marshalUriFromServer($server, $headers);
$method = ServerRequestFactory::get('REQUEST_METHOD', $server, 'GET');
$request = new ServerRequest($server, [], $uri, $method, $this->stdin, $headers);
return $request->withCookieParams($cookies)->withQueryParams($query)->withParsedBody($post);
}