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
相关产品推荐
相关产品推荐

