Laravel 7.28.3:主管在执行新作业时抛出错误**PHP致命错误:方法_exists()**
我已在laravel 7.28.3中创建了一个新作业,并从controller中分派。 我使用数据库作为队列连接,它的调度非常好(通过检查数据库作业表确认) 创建作业命令:Laravel 7.28.3:主管在执行新作业时抛出错误**PHP致命错误:方法_exists()**,laravel,laravel-7,supervisord,Laravel,Laravel 7,Supervisord,我已在laravel 7.28.3中创建了一个新作业,并从controller中分派。 我使用数据库作为队列连接,它的调度非常好(通过检查数据库作业表确认) 创建作业命令: php artisan make:job NewJob 当主管尝试运行作业时,会抛出以下错误 PHP致命错误:方法_exists():脚本试图执行方法或访问不完整对象的属性。请确保在调用unserialize()之前加载了您尝试操作的对象的类定义“App\Jobs\NewJob”,或提供自动加载程序来加载类定义 如果我启动
php artisan make:job NewJob
当主管尝试运行作业时,会抛出以下错误
PHP致命错误:方法_exists():脚本试图执行方法或访问不完整对象的属性。请确保在调用unserialize()之前加载了您尝试操作的对象的类定义“App\Jobs\NewJob”,或提供自动加载程序来加载类定义
如果我启动队列:手动工作,它工作正常,并使用以下命令显示作业结果:
{PROJECT_PATH}/artisan queue:work --tries=3 --timeout=0 --queue=default
迄今已采取的步骤:
- 重新加载的Supervisorctl
- 重新启动的管理器服务
- 已执行的编写器转储自动加载
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;
class NewJob implements ShouldQueue
{
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
/**
* Create a new job instance.
*
* @return void
*/
public function __construct()
{
}
/**
* Execute the job.
*
* @return void
*/
public function handle()
{
$message = "Test";
echo $message;
dd($message);
}
}
从控制器发送
dispatch(new NewJob());
管理器配置
[program:Notifications]
process_name=%(program_name)s_%(process_num)02d
command=php {PROJECT_PATH}/artisan queue:work --tries=3 --timeout=0 --queue=default
autostart=true
autorestart=true
user=root
numprocs=10
redirect_stderr=true
stdout_logfile={PROJECT_PATH}/storage/logs/notifications-worker.log
我已经通过配置Laravel Horizon解决了这个问题,它工作起来很有魅力:)