You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Laravel队列报错:Illuminate\Bus\Dispatcher需声明抽象或实现缺失方法

Laravel队列功能添加报错求助

我正尝试在现有Laravel项目中添加队列功能,参考相关教程后在全新Laravel项目中测试可正常运行,但现有项目报错。在相关社区找到类似问题但未找到解决方案,恳请帮助。

相关代码

EmployeesController.php

....
dispatch(new EmployeeListExportJob(['data'=>$data,'countries'=>$countries,'format'=>$request->format]));
....

EmployeeListExportJob.php

<?php

namespace App\Jobs;

use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Queue\SerializesModels;
use Excel;
use App\Exports\EmployeesExportExcel;

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


    protected $details;
    protected $data;
    protected $countries;
    protected $format;

    /**
     * Create a new job instance.
     *
     * @return void
     */
    public function __construct($details)
    {
        $this->data = $details['data'];
        $this->countries = $details['countries'];
        $this->format = $details['format'];
    }

    /**
     * Execute the job.
     *
     * @return void
     */
    public function handle()
    {
        Excel::download(new EmployeesExportExcel($this->data, $this->countries), 'Employees.xlsx');
    }
}

已尝试的方法及报错信息

我尝试过自定义调度器类、自定义队列类,还在EmployeeListExportJob类中添加了缺失的方法(findBatch、batch、dispatchSync),但均无效,仍报错:

类 Illuminate\Bus\Dispatcher 包含3个抽象方法,因此必须声明为抽象类或实现缺失的方法(Illuminate\Contracts\Bus\QueueingDispatcher::findBatch、Illuminate\Contracts\Bus\QueueingDispatcher::batch、Illuminate\Contracts\Bus\Dispatcher::dispatchSync)

内容的提问来源于stack exchange,提问作者Muhammed Shajeer

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.10 01:35:12