Php 取消序列化时Laravel通知失败
在我的forge生产服务器上,我已经配置了Laravel 5.3通知,所有通知都使用了Php 取消序列化时Laravel通知失败,php,laravel,Php,Laravel,在我的forge生产服务器上,我已经配置了Laravel 5.3通知,所有通知都使用了light\Bus\Queueable特性,并实现了light\Contracts\Queue\ShouldQueue接口。这是在我创建的App\Notifications\BaseNotification类中完成的,我的所有通知类都进行了扩展 我还配置了一个工人来运行队列 一切都正常,但今晚我在执行通知时开始收到此错误: Symfony\Component\Debug\Exception\FatalError
light\Bus\Queueable
特性,并实现了light\Contracts\Queue\ShouldQueue
接口。这是在我创建的App\Notifications\BaseNotification
类中完成的,我的所有通知类都进行了扩展
我还配置了一个工人来运行队列
一切都正常,但今晚我在执行通知时开始收到此错误:
Symfony\Component\Debug\Exception\FatalErrorException: Illuminate\Notifications\ChannelManager::sendNow(): The script tried to execute a method or access a property of an incomplete object. Please ensure that the class definition "CenaZero\Notifications\Orders\OrderCompletedOwnerNotification" of the object you are trying to operate on was loaded _before_ unserialize() gets called or provide a __autoload() function to load the class definition
in /home/forge/cenazero.com.br/vendor/laravel/framework/src/Illuminate/Notifications/ChannelManager.php:64
报告错误的类的代码如下所示:
<?php
namespace CenaZero\Notifications\Orders;
use CenaZero\Models\Order;
use CenaZero\Notifications\BaseNotification;
use Illuminate\Notifications\Messages\MailMessage;
use NotificationChannels\Gcm\GcmMessage;
use NotificationChannels\Zenvia\ZenviaMessage;
class OrderCompletedProducerNotification extends BaseNotification
{
private $order;
public function __construct(Order $order)
{
$this->order = $order;
}
public function toMail($notifiable)
{
$data = [
'order' => $this->order,
'item' => $this->order->item,
'product' => $this->order->item->product,
'producer' => $notifiable,
'to' => $notifiable->email,
];
return (new MailMessage)
->view(['emails.orders.completed.producer', 'emails.orders.completed.producer-plain'], $data)
->subject($this->translation('subject'));
}
public function toZenvia($notifiable)
{
return ZenviaMessage::create()
->content($this->translation('message'))
->id('order-completed-producer-' . $this->order->id);
}
public function toGcm($notifiable)
{
return GcmMessage::create()
->title($this->translation('title'))
->message($this->translation('message'));
}
public function toArray($notifiable)
{
return [
'id' => $this->order->id,
'status_id' => $this->order->status_id,
'message' => $this->translation('title'),
'description' => $this->translation('message'),
];
}
}
此部分来自给定的错误消息
...Please ensure that the class definition
"CenaZero\Notifications\Orders\OrderCompletedOwnerNotification"
of the object you are trying to operate on was loaded...
显示该类不是自动加载的
将包含在CenaZero
命名空间下使用的类的基本文件夹添加到的数组中。这样,在脚本尝试使用命名空间下的类反序列化对象之前,命名空间下的类将自动加载
composer.json
{
"autoload": {
"psr-4": {
"CenaZero\\": "<relative-path-to-root-folder-of-namespace>/",
}
}
}
{
“自动加载”:{
“psr-4”:{
“CenaZero\\”:“/”,
}
}
}