tanuck/pusher 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

tanuck/pusher

最新稳定版本:2.0.0

Composer 安装命令:

composer require tanuck/pusher

包简介

A CakePHP integration for the Pusher library.

README 文档

README

Build Status License Total Downloads

A CakePHP plugin for interaction with the Pusher API.

Installation

Include the following in your composer.json file:

{
	"require": {
		"tanuck/pusher": "dev-master"
	}
}

Note: This plugin should install in your Plugin directory rather than the composer vendors directory.

Configuration

Firstly, you must load the plugin:

CakePlugin::load('CakePusher');

Include the component in your controller:

class MyController extends AppController {

	public $components = array(
		'CakePusher.Pusher' => array(
			'auth_key' => 'PUSHER_APP_AUTH_KEY',
			'secret' => 'PUSHER_APP_SECRET',
			'app_id' => 'PUSHER_APP_ID',
		),
	);
}

This is the most basic form taken by the Component constructor, for further configuration options see the Usage section below.

Then access the Component like so:

$this->Pusher->trigger('my-channel', 'my-event', 'My Message');

Usage

If you wish to use just the one Pusher app in your CakePHP application, then the $components definition above will be enough. The options available mirror those passed to the Pusher API constructor (see here form more information).

The plugin allows you to configure and use multiple Pusher apps with the Component. This can be done by nesting the configuration arrays in the component settings, the array index of each will become the internal alias to each Pusher app. For example:

class MyController extends AppController {

	public $components = array(
		'CakePusher.Pusher' => array(
			'main' => array(
				'auth_key' => 'PUSHER_APP_AUTH_KEY',
				'secret' => 'PUSHER_APP_SECRET',
				'app_id' => 'PUSHER_APP_ID',
			),
			'otherApp' => array(
				'auth_key' => 'PUSHER_APP_AUTH_KEY',
				'secret' => 'PUSHER_APP_SECRET',
				'app_id' => 'PUSHER_APP_ID',
			),
		),
	);
}

NOTE: When using more than one Pusher instance you must specifiy a main app.

You can interact with the default main app using the methods directly on the component or you can specify an app to use with the with method:

$this->Pusher->trigger('my-channel', 'my-event', 'My Message');
$this->Pusher->socketAuth('my-channel', '1234.1234');
$this->Pusher->presenceAuth('my-channel', '1234.1234', 'user-12', true);
$this->Pusher->get('/channels');

$this->Pusher->with('otherApp')->trigger('my-channel', 'my-event', 'My Message');

You can get and set the name of the default Pusher app like so:

$this->Pusher->getDefault();

$this->Pusher->setDefault('otherApp');

And you can add additional app configurations on the fly:

$this->Pusher->addAppConfig('myAppName', array(
	'auth_key' => 'PUSHER_APP_AUTH_KEY',
	'secret' => 'PUSHER_APP_SECRET',
	'app_id' => 'PUSHER_APP_ID',
));

License

cakephp-pusher is offered under an MIT license.

统计信息

  • 总下载量: 56
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 1
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 1
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2015-08-14

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固