title: Using Guzzle promises asyncronously
body: <p>I am attempting to use <a href="https://github.com/guzzle/promises" rel="noreferrer">guzzle promises</a> in order to make some http calls, to illustrate what I have, I have made this simple example where a fake http request would take 5 seconds:</p>
  
  <pre><code>$then = microtime(true);
  
  $promise = new Promise(
      function() use (&amp;$promise) {
          //Make a request to an http server
          $httpResponse = 200;
          sleep(5);
          $promise-&gt;resolve($httpResponse);
      });
  
  $promise2 = new Promise(
      function() use (&amp;$promise2) {
          //Make a request to an http server
          $httpResponse = 200;
          sleep(5);
          $promise2-&gt;resolve($httpResponse);
      });
  
  echo 'PROMISE_1 ' . $promise-&gt;wait();
  echo 'PROMISE_2 ' . $promise2-&gt;wait();
  
  echo 'Took: ' . (microtime(true) - $then);
  </code></pre>
  
  <p>Now what I would want to do is start both of them, and then make both echo's await for the response. What actually happens is promise 1 fires, waits 5 seconds then fires promise 2 and waits another 5 seconds.</p>
  
  <p>From my understanding I should maybe be using the <code>-&gt;resolve();</code> function of a promise to make it start, but I dont know how to pass resolve a function in which I would make an http call</p>