title: How to work with multiple threads while a single request in Laravel?
body: <p>I want to get 10 elements array from backend and show it on a frontend. Let's image that every element of array needs 10 seconds to build.<br />
  I do a single post request.
  In my controller:</p>
  <pre class="lang-php prettyprint-override"><code>...
  $arr = [];
  for ($i = 0; $i &lt; 10: ++$i) {
    $arr[] = (new MyObject($i))-&gt;build(); // takes 10 seconds
  }
  return response()-&gt;json(['data' =&gt; $arr])
  </code></pre>
  <p>In that case I need 100 seconds to get all needed data.</p>
  <p>I would want to parallelize this cycle somehow. I want each turn of the cycle to be executed in a separate thread and then data from every thread build up into one array. And this array will be sent to the front-end. In that case I think that whole operation will take 10-12 seconds.</p>
  <p>Is there a way I can do it in Laravel?</p>