Laravel 8 没有广播事件(推送者)

Laravel 8 not broadcasting an event (pusher)

我刚开始使用 laravel pusher。广播事件时出现此错误。我可以看到事件正在 pusher degub console 中触发。我不明白这个错误与什么有关。我需要帮助来了解我哪里出错了。

{message: "Undefined property: stdClass::$channels", exception: "ErrorException",…}
exception: "ErrorException"
file: "C:\xampp\htdocs\realtimechat\vendor\pusher\pusher-php-server\src\Pusher.php"
line: 538
message: "Undefined property: stdClass::$channels"
trace: [{file: "C:\xampp\htdocs\realtimechat\vendor\pusher\pusher-php-server\src\Pusher.php", line: 538,…},…]

这是我的代码

 public function sendMessage(Request $request)
    {
       event(new MessageEvent());
    }

活动


class MessageEvent implements ShouldBroadcast
{
    use Dispatchable, InteractsWithSockets, SerializesModels;

    

    public function __construct()
    {
        
    }

    /**
     * Get the channels the event should broadcast on.
     *
     * @return \Illuminate\Broadcasting\Channel|array
     */
    public function broadcastOn()
    {
        return new Channel('channel-name');
    }

    public function broadcastAs()
    {
        return 'userChatChannel';
    }
}

谢谢

有关详细信息,您可以阅读以下想法

https://github.com/pusher/pusher-http-php/issues/295

问题是版本推送器 5.0 已损坏。所以要解决这个问题,您必须编辑 composer.json 文件

来自

"pusher/pusher-php-server": "5.0"

"pusher/pusher-php-server": "^5.0"

在此 运行 composer update 命令之后