首页 文章

包括10月CMS中的Pusher php服务器和vinkla / pusher桥

提问于
浏览
1

我试图构建一个在Pusher上运行的简单聊天插件 . 我一直在关注为Laravel编写的this tutorial,以及10月份的文档 .

我采取的步骤:

  • 通过作曲家安装了10月

然后如教程中所述:

然后在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 回答

  • 1

    事实证明,在Pusher示例中,'encrypted'的默认选项设置为true,从配置文件中删除此选项解决了问题 .

    我的config / pusher.php看起来像这样

    'connections' => [
    
        'main' => [
            'auth_key' => 'put auth key here',
            'secret' => 'put secret key here',
            'app_id' => 'put app id here',
            'options' => ['cluster' => 'eu'],
            'host' => null,
            'port' => null,
            'timeout' => null,
        ],
    

相关问题