我使用 zts-php 进行线程工作我有关闭错误guzzle客户端不是序列化$this->client
,我使用$client
工作如何添加run()
函数guzzlehttp client
?
use GuzzleHttp\Client;
use GuzzleHttp\Promise\EachPromise;
use GuzzleHttp\TransferStats;
use Psr\Http\Message\ResponseInterface;
use GuzzleHttp\Promise\PromiseInterface;
class check extends Thread
{
function __construct(string $url,int $timeout=60)
{
$this->client= new Client([
'timeout' => $timeout
]);
$this->timeout = $this->timeout;
}
public function run() {
$response = $this->client->request('head', "http://www.google.com", [
'on_stats' => function (TransferStats $stats) {
$this->uri = $stats->getEffectiveUri();
$this->transferTime = $stats->getTransferTime();
}
]);
}
}
我得到错误:
Fatal error: Uncaught Exception: Serialization of 'Closure' is not allowed in