I am trying to use Guzzle pool in Symfony 2 application. I am thinking to use it because its capability of sending concurrent request at once.
However, since its async in nature I am not sure how can I use it as service in Symfony 2. Since return are not always immediate.
For example lets say I have service called Foo in Symfony which have method like this some what.
function test()
{
$request = $client->createRequest('GET', 'http://lt/?n=0', ['future' => true]);
$client->send($request)->then(function ($response) {
return "\n".$response->getBody();
});
}
Now I invoke this service like this.
$service = $this->get('foo');
$result = $service->test();
echo $result;// does not work :( echoes out null
Is there any way to get around this problem. I really want to use Future since I need async feature.