How to perform multiple Guzzle requests at the same time?

前端 未结 3 1207
攒了一身酷
攒了一身酷 2020-12-04 19:44

I can perform single requests using Guzzle and I\'m very pleased with Guzzle\'s performance so far however, I read in the Guzzle API something about MultiCurl and Batching.<

3条回答
  •  一个人的身影
    2020-12-04 20:31

    From the docs: http://guzzle3.readthedocs.org/http-client/client.html#sending-requests-in-parallel

    For an easy to use solution that returns a hash of request objects mapping to a response or error, see http://guzzle3.readthedocs.org/batching/batching.html#batching

    Short example:

    send(array(
        $client->get('http://www.example.com/foo'),
        $client->get('http://www.example.com/baz'),
        $client->get('http://www.example.com/bar')
    ));
    

提交回复
热议问题