【问题标题】:Including Pusher php server in OctoberCMS with vinkla/pusher bridge包括带有vinkla/pusher桥的OctoberCMS中的Pusher php服务器
【发布时间】:2016-11-04 18:15:32
【问题描述】:

我在 10 月的 CMS 中开始构建网站,现在我正在尝试构建一个在 Pusher 上运行的简单聊天插件。我一直在关注为 Laravel 编写的 this tutorial,并结合了 10 月份的文档。

我已采取的步骤:

  • 10 月通过 composer 安装

然后按照教程中的描述:

然后在cms中我用组件制作了一个新的聊天插件,并在Plugin.php文件的boot()函数中注册了服务提供者:

plugins/oda/chat/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上描述的简单测试代码:

plugins/oda/chat/components/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);
 }

...

}

我将组件添加到页面并检查了推送器仪表板调试,但没有收到任何内容。页面本身也没有错误。

【问题讨论】:

  • 你的插件发布了吗?我正在做一个类似的项目,并想检查它是否可用。谢谢

标签: php laravel-5 pusher octobercms


【解决方案1】:

事实证明,在 Pusher 示例的默认选项中,“加密”设置为 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,
    ],

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-01-29
    • 1970-01-01
    • 2020-05-14
    • 2018-06-08
    • 2022-12-05
    • 1970-01-01
    相关资源
    最近更新 更多