0

Is there any way to run mutiple independent function asynchronously in request controller without putting it in queue?

public function exampleFunction(Request $request){

    // These are independent functions
    $one = $this->oneFunction();
    $two = $this->anotherFunction();
    $three = $this->differentFunction();

    return response()->json([
        'one'=>$one,
        'two'=> $two,
        'three'=>$three
    ]);
}
shalonteoh
  • 1,994
  • 2
  • 15
  • 17
  • https://stackoverflow.com/questions/13846192/php-threading-call-to-a-php-function-asynchronously – J. Doe Jul 25 '18 at 08:26
  • Well, solution for long running task is simply using queue + cache (in your example). Not possible via queues you need to leverage [pthreads](http://php.net/manual/en/book.pthreads.php) I bet there are packages that simplify / abstract the API. Good luck and forge some nerves of steel along the way. Also you could use JavaScript to call 3 endpoints and join the results in the JS. – Kyslik Jul 25 '18 at 08:26

0 Answers0