You are here

public static function ServerRequestFactory::fromGlobals in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 vendor/zendframework/zend-diactoros/src/ServerRequestFactory.php \Zend\Diactoros\ServerRequestFactory::fromGlobals()

Create a request from the supplied superglobal values.

If any argument is not supplied, the corresponding superglobal value will be used.

The ServerRequest created is then passed to the fromServer() method in order to marshal the request URI and headers.

Parameters

array $server $_SERVER superglobal:

array $query $_GET superglobal:

array $body $_POST superglobal:

array $cookies $_COOKIE superglobal:

array $files $_FILES superglobal:

Return value

ServerRequest

Throws

InvalidArgumentException for invalid file values

See also

fromServer()

1 call to ServerRequestFactory::fromGlobals()
Server::createServer in vendor/zendframework/zend-diactoros/src/Server.php
Create a Server instance

File

vendor/zendframework/zend-diactoros/src/ServerRequestFactory.php, line 53

Class

ServerRequestFactory
Class for marshaling a request object from the current PHP environment.

Namespace

Zend\Diactoros

Code

public static function fromGlobals(array $server = null, array $query = null, array $body = null, array $cookies = null, array $files = null) {
  $server = static::normalizeServer($server ?: $_SERVER);
  $files = static::normalizeFiles($files ?: $_FILES);
  $headers = static::marshalHeaders($server);
  $request = new ServerRequest($server, $files, static::marshalUriFromServer($server, $headers), static::get('REQUEST_METHOD', $server, 'GET'), 'php://input', $headers);
  return $request
    ->withCookieParams($cookies ?: $_COOKIE)
    ->withQueryParams($query ?: $_GET)
    ->withParsedBody($body ?: $_POST);
}