Laravel的`broadcast`函数什么都不做

时间:2018-07-10 07:11:29

标签: php laravel websocket broadcast

在具有Apache2的Ubuntu上运行Laravel 5.5,PHP 7.0。

我有这行代码:

broadcast(new \App\Events\Event("test"));

我将广播公司设置为/config/broadcasting.php中的“ log”:

'default' => "log",

我在两个地方的BroadcastServiceProvider中都启用了app.php

但是,storage/logs/laravel.log中没有任何记录。 (其他日志看起来很好)

我也尝试将广播者设置为redis,但是即使redis工作正常,广播事件也不会创建Redis::set()值/密钥对。

我错过了一步吗?要使广播功能正常工作,我还需要做什么?

1 个答案:

答案 0 :(得分:1)

在事件上实现ShouldBroadcast界面
https://laravel.com/docs/5.6/broadcasting#using-example-application

供参考,如下所示:

enter image description here