Skip to content
This repository has been archived by the owner on Aug 31, 2020. It is now read-only.

Latest commit

 

History

History
41 lines (32 loc) · 983 Bytes

readme.md

File metadata and controls

41 lines (32 loc) · 983 Bytes

Laravel PubNub

This is a really light wrapper for the PubNub API. It comes with a simple demo. You can delete controllers/, views/ and routes.php if not needed.

Installation

Just register the bundle

'pubnub' => array(
	'auto'    => true,
	// Want to use the demo?
	'handles' => 'pubnub',
)

Usage

  1. Edit config/pubnub.php
  2. Call PubNub using the IoC Resolver.

You can use use any functionality provided by PubNub.

Publish

IoC::resolve('pubnub')->publish(array(
	'channel' => 'my_channel',
	'message' => array( 'my_var' => 'my text data' )
));

Subscribe

IoC::resolve('pubnub')->subscribe(array(
	'channel ' => 'my_channel',
	'callback' => function($message) {
		var_dump($message['my_var']); // print message
		return true;             // keep listening?
	}
));

History

$messages = IoC::resolve('pubnub')->history(array(
	'channel' => 'my_channel',
	'limit'   => 10
));