【发布时间】:2016-11-04 18:15:32
【问题描述】:
我在 10 月的 CMS 中开始构建网站,现在我正在尝试构建一个在 Pusher 上运行的简单聊天插件。我一直在关注为 Laravel 编写的 this tutorial,并结合了 10 月份的文档。
我已采取的步骤:
- 10 月通过 composer 安装
然后按照教程中的描述:
- 通过composer安装vinkla/pusher包
- 发布包并设置配置
然后在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