0

in laravel is there a way to run code in the background?

For example:

public function video_merge()
{
    $video1="video1.mp4";
    $video2="video2.mp4";
    $cmd="command to merge video1 and video2";
    $id="xxxxxxxxxxxxx";//This "ID" I will use to check if the video has been merged
    //this code i want it to run in the background

    exec($cmd);
    updateStatusMerge($id,'ready'); //This function I will use to update the status is: video merging completed

    //end code running in the background

    return response()->json([
        'status'=>'processing',
        'id'=>$id 
    ]);
}

In the above code I want to merge two videos video1.mp4 and video2.mp4 with ffmpeg command how to make exec($cmd); updateStatusMerge($id,'ready'); run in the background

Any documents or suggestions?

lCode
  • 1
  • 1
  • Does this help https://stackoverflow.com/questions/69917538/laravel-8-how-to-run-a-job-script-in-the-background – RiggsFolly Mar 06 '23 at 14:05
  • You can use [Artisan](https://laravel.com/docs/10.x/artisan) and/or [Queues](https://laravel.com/docs/10.x/queues) – aynber Mar 06 '23 at 14:09

0 Answers0