php – 如何发布Guzzle 6异步数据

我试图使用Guzzle 6(最新版本)将数据发布为Async

    $client = new Client();
    $request = $client->postAsync($url, [
        'json' => [
                'company_name' => 'update Name'
        ],
    ]);

但我没有得到任何形式的Guzzle请求,如终端上的帖子请求

最佳答案 您是否尝试过发送请求?

http://guzzle.readthedocs.org/en/latest/index.html?highlight=async

$client = new Client();
$request = new Request('POST', $url, [
    "json" => [
        'company_name' => 'update Name']
    ]);

$promise = $client->sendAsync($request)->then(function ($response) {
    echo 'I completed! ' . $response->getBody();
});
$promise->wait();
点赞