function Client::__construct
Same name in this branch
- 11.1.x vendor/php-http/guzzle7-adapter/src/Client.php \Http\Adapter\Guzzle7\Client::__construct()
Clients accept an array of constructor parameters.
Here's an example of creating a client using a base_uri and an array of default request options to apply to each request:
$client = new Client([ 'base_uri' => 'http://www.foo.com/1.0/', 'timeout' => 0, 'allow_redirects' => false, 'proxy' => '192.168.16.1:10' ]);
Client configuration settings include the following options:
- handler: (callable) Function that transfers HTTP requests over the wire. The function is called with a Psr7\Http\Message\RequestInterface and array of transfer options, and must return a GuzzleHttp\Promise\PromiseInterface that is fulfilled with a Psr7\Http\Message\ResponseInterface on success. If no handler is provided, a default handler will be created that enables all of the request options below by attaching all of the default middleware to the handler.
- base_uri: (string|UriInterface) Base URI of the client that is merged into relative URIs. Can be a string or instance of UriInterface.
- **: any request option
Parameters
array $config Client configuration settings.:
See also
RequestOptions for a list of available request options.
File
-
vendor/
guzzlehttp/ guzzle/ src/ Client.php, line 57
Class
- Client
- @final
Namespace
GuzzleHttpCode
public function __construct(array $config = []) {
if (!isset($config['handler'])) {
$config['handler'] = HandlerStack::create();
}
elseif (!\is_callable($config['handler'])) {
throw new InvalidArgumentException('handler must be a callable');
}
// Convert the base_uri to a UriInterface
if (isset($config['base_uri'])) {
$config['base_uri'] = Psr7\Utils::uriFor($config['base_uri']);
}
$this->configureDefaults($config);
}