a3020 / guzzle-mutable-config
具有可变配置的 Guzzle 客户端
0.1.3
2016-10-03 13:29 UTC
Requires
- guzzlehttp/guzzle: ~6.2
Requires (Dev)
- phpunit/phpunit: ^4.0
This package is auto-updated.
Last update: 2024-09-09 21:29:40 UTC
README
默认情况下,Guzzle 配置是不可变的。它只能通过构造函数设置,并通过 getConfig 获取。
如果您需要爬取不同的域名,例如,您可能希望更改 base_uri 而不是创建数百个实例。这是 Guzzle 客户端实现的副本,增加了两个额外的方法
setConfig(array $array)
setConfigOption(string $key, $value)
安装
composer require "a3020/guzzle-mutable-config"
用法
$client = new A3020\GuzzleHttp\Client([ 'base_uri' => 'foo', ]); $client->setConfigOption('base_uri', 'https://'); $response = $client->get('file.htm');