相关疑难解决方法(0)

Laravel 队列“Closure”序列化是不允许的

我需要帮助来使用 Laravel 分派作业,似乎系统在使用队列作业时尝试序列化闭包,因此出现此错误。

我该如何解决这个问题?我也尝试过这个包
https://github.com/jeremeamia/super_closure
但它在我的情况下不起作用。

这是我的代码:

在控制器 FacebookController 中:

public function getPosts(\SammyK\LaravelFacebookSdk\LaravelFacebookSdk $fb) //get all post of logged user
{
    dispatch(new SyncFacebook($fb));
}
Run Code Online (Sandbox Code Playgroud)

以及要调度的作业:

<?php

namespace App\Jobs;

use Illuminate\Bus\Queueable;
use Illuminate\Queue\SerializesModels;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable;

use Session, DB, Carbon\Carbon, Auth;

use App\{
    User, Reaction, Post, Synchronisation
};

class SyncFacebook implements ShouldQueue
{
    use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;

    protected $fb;

    public function __construct($fb)
    {
        $this->fb = $fb;
    }

    public function handle()
    {
        set_time_limit(0);
        $user = Auth::user();

        try { …
Run Code Online (Sandbox Code Playgroud)

php queue closures laravel

1
推荐指数
1
解决办法
7656
查看次数

标签 统计

closures ×1

laravel ×1

php ×1

queue ×1