Ping使用Guzzle Http php

时间:2017-05-29 07:12:52

标签: php guzzle

我想用guzzle http来ping。 我不关心反应。 只要求就够了。 无需回复。 请求后代码需要退出。不要等待回应。

我尝试使用异步。

<?php
require_once "vendor/autoload.php";

$client = new GuzzleHttp\Client();

$promise1 = $client->requestAsync('GET', 'http://localhost/test/?id=from_async1');

$promise2 = $client->requestAsync('GET', 'http://localhost/test/?id=from_async2');

$promise3 = $client->requestAsync('GET', 'http://localhost/test/?id=from_async3');

$promise1->then(function (ResponseInterface $response) {

});

$promise2->then(function (ResponseInterface $response) {

});

$promise3->then(function (ResponseInterface $response) {

});
$promise1->wait();

$promise2->wait();

$promise3->wait();

但是这个脚本仍然等待所有回复。

如何在不等待响应的情况下使脚本正常工作?有什么想法吗?

0 个答案:

没有答案