Download the PHP package auraeq/pubnub-laravel without Composer
On this page you can find all versions of the php package auraeq/pubnub-laravel. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package pubnub-laravel
pubnub-laravel
NOTE This is a beta release.
This is a nice, clean, OOP Laravel 4 wrapper for Pubnub's terrible php library.
All of the (useful) public methods of the base library have been wrapped and exposed with proper parameters, consistent return values, and actual exceptions instead of incomprehensible array-errors.
Two methods have not been wrapped or exposed: history()
and detailedHistory()
, because they return a completely metadata-less array of messages that isn't actually that useful.
Here are some things still to do. Got some time and a good brain? Submit a pull request!
- [ ] Write some tests. Not sure how best to do this, we'd need to mock the Pubnub calls somehow.
- [ ] You can't work with more than one channel at once; this is a restriction of the base library, but maybe one that could be worked around?
- [ ] I'm not an expert in this sort of blocking architecture. There may be a better way to implement the
subscribe()
method, but I'm not sure what it is at this stage. - [ ] Maybe figure out the history and detailedHistory methods.
- [ ] The
presence()
method doesn't seem to do anything, at least in my brief testing. I think it's just borken? On that note: - [ ] Maybe stop wrapping the base library and just rewrite the whole damn thing cause seriously what is it up to.
Installing
To install, add the package to your composer.json
:
then run composer update
.
Add the following to your config/app.php
under 'providers'
:
And then add the following to your config/app.php
under 'aliases'
:
You'll also want to publish the config file:
And then configure at least your 'origin'
, 'publish_key'
and 'subscriber_key'
.
Usage
To set the channel:
You can also set to channel for each method individually, as outlined below. If you try to use a method without having a channel set, a PubnubChannelException
will be thrown.
To publish a message:
Returns true
on success or throws PubnubPublishFailedException
on failure.
Note This method is blocking. It will never end until there's an error, you return false from your callback, or php times out (I guess).
To subscribe to a message:
Returns true
on success or throws PubnubSubscribeFailedException
on failure.
There is also a presence()
method with the same signature that is supposed to notify you of arrivals/departures in the channel you're subscribed to, but it doesn't seem to work (see note above).
To see who's currently subscribed:
Returns an array of UUIDs from Pubnub.