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



我刚开始使用laravel pusher。当广播一个事件时,我收到了这个错误。我可以看到事件正在pusher degub console中启动。我不明白这个错误与什么有关。我需要帮助来了解我哪里出了问题。

{message: "Undefined property: stdClass::$channels", exception: "ErrorException",…}
exception: "ErrorException"
file: "C:xampphtdocsrealtimechatvendorpusherpusher-php-serversrcPusher.php"
line: 538
message: "Undefined property: stdClass::$channels"
trace: [{file: "C:xampphtdocsrealtimechatvendorpusherpusher-php-serversrcPusher.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 IlluminateBroadcastingChannel|array
*/
public function broadcastOn()
{
return new Channel('channel-name');
}
public function broadcastAs()
{
return 'userChatChannel';
}
}

谢谢

有关详细信息,您可以通过以下思考

https://github.com/pusher/pusher-http-php/issues/295
https://stackoverflow.com/questions/66624416/pusher-undefined-property-stdclasschannels-in-laravel-lumen

问题是版本推进器5.0坏了。所以要解决这个问题,你必须编辑你的composer.json文件

来自

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

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

运行composer update命令之后

最新更新