Php Laravel 5:执行异步任务

Php Laravel 5:执行异步任务,php,laravel,asynchronous,Php,Laravel,Asynchronous,我有以下功能,其中我处理类型为UploadedFile的图像文件,将其作为随机名称,使用\Intervention\image以不同大小存储,然后返回图像名称 存储部分需要很多时间,请求通常超时。如果我可以在单独的线程或进程中进行处理,并返回图像名称,那就太好了。以下是我的代码: public function storeSnapshots(UploadedFile $image) { // Generate a random image name. $imageName = s

我有以下功能,其中我处理类型为
UploadedFile
的图像文件,将其作为随机名称,使用
\Intervention\image
以不同大小存储,然后返回图像名称

存储部分需要很多时间,请求通常超时。如果我可以在单独的线程或进程中进行处理,并返回图像名称,那就太好了。以下是我的代码:

public function storeSnapshots(UploadedFile $image) {
    // Generate a random image name.
    $imageName = str_random(12) . '.' . $image->getClientOriginalExtension();

    // Process the image. Should be done asynchronously.
    \Intervention\Image\Facades\Image::make($image)
        ->heighten(2000, function($constraint) {
            $constraint->upsize();
        })->save('img/lg/' . $imageName)
        ->heighten(800)->save('img/md/' . $imageName)
        ->heighten(120)->save('img/sm/' . $imageName);

    // Return the image name generated.
    return $imageName;
}

Laravel执行异步任务的方式是什么?

Laravel通过执行异步任务