我试图构建一个在Pusher上运行的简单聊天插件 . 我一直在关注为Laravel编写的this tutorial,以及10月份的文档 .
我采取的步骤:
- 通过作曲家安装了10月
然后如教程中所述:
-
通过composer安装vinkla/pusher包
-
发布包并设置配置
然后在cms中我用一个组件创建了一个新的Chat插件,并在Plugin.php文件的boot()函数中注册了服务提供者:
插件/ ODA /聊天/ Plugin.php
<?php namespace Oda\Chat;
use Backend;
use App;
use System\Classes\PluginBase;
class Plugin extends PluginBase
{
...
public function boot()
{
App::register('Vinkla\Pusher\PusherServiceProvider');
}
...
}
在我的插件组件中,我添加了vinkla / pusher github中描述的简单测试代码:
插件/ ODA /聊天/组件/ Chat.php
<?php namespace Oda\Chat\Components;
use Cms\Classes\ComponentBase;
use Vinkla\Pusher\Facades\Pusher;
class Chat extends ComponentBase
{
...
public function onRun()
{
$data['message'] = 'hello world';
Pusher::trigger('my-channel', 'my-event', $data);
}
...
}
我将组件添加到页面并检查推送仪表板调试,但没有收到任何内容 . 页面本身也没有错误 .
1 回答
事实证明,在Pusher示例中,'encrypted'的默认选项设置为true,从配置文件中删除此选项解决了问题 .
我的config / pusher.php看起来像这样