2017 © Pedro Peláez
 

library pubnub

The Only Global Network For Real-Time Data -- PubNub!

image

pubnub/pubnub

The Only Global Network For Real-Time Data -- PubNub!

  • Wednesday, December 6, 2017
  • by pubnub
  • Repository
  • 42 Watchers
  • 93 Stars
  • 485,735 Installations
  • PHP
  • 15 Dependents
  • 1 Suggesters
  • 94 Forks
  • 9 Open issues
  • 35 Versions
  • 5 % Grown

The README.md

PubNub PHP SDK (V4)

Build Status codecov Docs GitHub release (latest by date), (*1)

This is the official PubNub PHP SDK repository., (*2)

PubNub takes care of the infrastructure and APIs needed for the realtime communication layer of your application. Work on your app's logic and let PubNub handle sending and receiving data across the world in less than 100ms., (*3)

The SDK supports PHP 7.4 and 8.x., (*4)

Get keys

You will need the publish and subscribe keys to authenticate your app. Get your keys from the Admin Portal., (*5)

Configure PubNub

  1. Integrate the PHP SDK into your project:
  • Without composer, (*6)

    1. Clone the following repository: git clone https://github.com/pubnub/php.git ./pubnub-php
    2. Copy the src folder to your project.
    3. Include autoloader.php file in your project:, (*7)

      php require_once('src/autoloader.php');, (*8)

    4. Download dependency monolog from https://github.com/Seldaek/monolog and copy the monolog folder from the src folder to the src folder of your project., (*9)

    5. Download dependency psr/Log from https://github.com/php-fig/log/tree/master and copy the psr folder to the src folder of your project.
    6. Download dependency rmccue from https://github.com/WordPress/Requests and copy the Requests folder and the file Requests.php from the library folder to the src folder of your project.
  • With composer, (*10)

    1. Add the PubNub package to your composer.json file:, (*11)

      json { "require": { <!-- include the latest version from the badge at the top --> "pubnub/pubnub": "7.1.0" } }, (*12)

    2. Run composer install --no-dev‌ from the command line. This installs the PubNub PHP SDK and all its dependencies in the vendor folder of the project., (*13)

    3. Include autoload.php file in your project:, (*14)

      php require_once('vendor/autoload.php');‌, (*15)

  1. Configure your keys:, (*16)

    $pnconf = new PNConfiguration();
    $pubnub = new PubNub($pnconf);
    
    $pnconf->setSubscribeKey("mySubscribeKey");
    $pnconf->setPublishKey("myPublishKey");
    $pnconf->setUserId("ReplaceWithYourClientIdentifier");
    

Add event listeners

class MySubscribeCallback extends SubscribeCallback {
    function status($pubnub, $status) {
        if ($status->getCategory() === PNStatusCategory::PNUnexpectedDisconnectCategory) {
        // This event happens when radio / connectivity is lost
        } else if ($status->getCategory() === PNStatusCategory::PNConnectedCategory){
        // Connect event. You can do stuff like publish, and know you'll get it // Or just use the connected event to confirm you are subscribed for // UI / internal notifications, etc
        } else if ($status->getCategory() === PNStatusCategory::PNDecryptionErrorCategory){
        // Handle message decryption error. Probably client configured to // encrypt messages and on live data feed it received plain text.
        }
    }
    function message($pubnub, $message){
    // Handle new message stored in message.message
    }
    function presence($pubnub, $presence){
    // handle incoming presence data
    }
}

$subscribeCallback = new MySubscribeCallback();
$pubnub->addListener($subscribeCallback);

Publish/subscribe

$pubnub->subscribe()
    ->channels("hello_world")
    ->execute();

$pubnub->publish()
    ->channel("hello_world")
    ->message("Hello PubNub!")
    ->sync();

Documentation

Support

If you need help or have a general question, contact support@pubnub.com., (*17)

The Versions

06/12 2017

dev-develop

dev-develop http://www.pubnub.com/

The Only Global Network For Real-Time Data -- PubNub!

  Sources   Download

MIT

The Requires

 

The Development Requires

by Avatar pubnub

api ajax realtime push real time real-time

15/11 2017

dev-master

9999999-dev http://www.pubnub.com/

The Only Global Network For Real-Time Data -- PubNub!

  Sources   Download

MIT

The Requires

 

The Development Requires

by Avatar pubnub

api ajax realtime push real time real-time

15/11 2017

dev-crimsonred-patch-1

dev-crimsonred-patch-1 http://www.pubnub.com/

The Only Global Network For Real-Time Data -- PubNub!

  Sources   Download

MIT

The Requires

 

The Development Requires

by Avatar pubnub

api ajax realtime push real time real-time

10/11 2017

dev-JeffGreen7-sourceclr

dev-JeffGreen7-sourceclr http://www.pubnub.com/

The Only Global Network For Real-Time Data -- PubNub!

  Sources   Download

MIT

The Requires

 

The Development Requires

by Avatar pubnub

api ajax realtime push real time real-time

14/06 2017

dev-edge

dev-edge http://www.pubnub.com/

The Only Global Network For Real-Time Data -- PubNub!

  Sources   Download

MIT

The Requires

 

The Development Requires

by Avatar pubnub

api ajax realtime push real time real-time

08/06 2017

4.0.0

4.0.0.0 http://www.pubnub.com/

The Only Global Network For Real-Time Data -- PubNub!

  Sources   Download

MIT

The Requires

 

The Development Requires

by Avatar pubnub

api ajax realtime push real time real-time

05/05 2017

4.0.0-beta.3

4.0.0.0-beta3 http://www.pubnub.com/

The Only Global Network For Real-Time Data -- PubNub!

  Sources   Download

MIT

The Requires

 

The Development Requires

by Avatar pubnub

api ajax realtime push real time real-time

21/04 2017

4.0.0-beta.2

4.0.0.0-beta2 http://www.pubnub.com/

The Only Global Network For Real-Time Data -- PubNub!

  Sources   Download

MIT

The Requires

 

The Development Requires

by Avatar pubnub

api ajax realtime push real time real-time

18/04 2017

4.0.0-beta

4.0.0.0-beta http://www.pubnub.com/

The Only Global Network For Real-Time Data -- PubNub!

  Sources   Download

MIT

The Requires

 

The Development Requires

by Avatar pubnub

api ajax realtime push real time real-time

05/04 2017

4.0.0-alpha

4.0.0.0-alpha http://www.pubnub.com/

The Only Global Network For Real-Time Data -- PubNub!

  Sources   Download

MIT

The Requires

 

The Development Requires

by Avatar pubnub

api ajax realtime push real time real-time

08/10 2016

3.8.3

3.8.3.0 http://www.pubnub.com/

The Only Global Network For Real-Time Data -- PubNub!

  Sources   Download

MIT

The Requires

  • php >=5.3.0

 

The Development Requires

by Avatar pubnub

api ajax realtime push real time real-time

08/10 2016

dev-master_3x

dev-master_3x http://www.pubnub.com/

The Only Global Network For Real-Time Data -- PubNub!

  Sources   Download

MIT

The Requires

  • php >=5.3.0

 

The Development Requires

by Avatar pubnub

api ajax realtime push real time real-time

17/02 2016

3.8.1

3.8.1.0 http://www.pubnub.com/

The Only Global Network For Real-Time Data -- PubNub!

  Sources   Download

MIT

The Requires

  • php >=5.3.0

 

The Development Requires

by Avatar pubnub

api ajax realtime push real time real-time

20/01 2016

3.8.0

3.8.0.0 http://www.pubnub.com/

The Only Global Network For Real-Time Data -- PubNub!

  Sources   Download

MIT

The Requires

  • php >=5.3.0

 

The Development Requires

by Avatar pubnub

api ajax realtime push real time real-time

24/07 2015

v3.7.9

3.7.9.0 http://www.pubnub.com/

The Only Global Network For Real-Time Data -- PubNub!

  Sources   Download

MIT

The Requires

  • php >=5.3.0

 

The Development Requires

by Dmitry Medvedev
by Victor Kislichenko
by PubNub Support

api ajax realtime push real time real-time

21/07 2015

v3.7.8

3.7.8.0 http://www.pubnub.com/

The Only Global Network For Real-Time Data -- PubNub!

  Sources   Download

MIT

The Requires

  • php >=5.3.0

 

The Development Requires

by Dmitry Medvedev
by Victor Kislichenko
by PubNub Support

api ajax realtime push real time real-time

02/07 2015

dev-taxitech

dev-taxitech http://www.pubnub.com/

The Only Global Network For Real-Time Data -- PubNub!

  Sources   Download

MIT

The Requires

  • php >=5.3.0

 

The Development Requires

by Dmitry Medvedev
by Victor Kislichenko
by PubNub Support

api ajax realtime push real time real-time

01/07 2015

v3.7.7

3.7.7.0 http://www.pubnub.com/

The Only Global Network For Real-Time Data -- PubNub!

  Sources   Download

MIT

The Requires

  • php >=5.3.0

 

The Development Requires

by Dmitry Medvedev
by Victor Kislichenko
by PubNub Support

api ajax realtime push real time real-time

09/06 2015

dev-fix-3.7.7

dev-fix-3.7.7 http://www.pubnub.com/

The Only Global Network For Real-Time Data -- PubNub!

  Sources   Download

MIT

The Requires

  • php >=5.3.0

 

The Development Requires

by Dmitry Medvedev
by Victor Kislichenko
by PubNub Support

api ajax realtime push real time real-time

30/05 2015

dev-DESK-12949

dev-DESK-12949 http://www.pubnub.com/

The Only Global Network For Real-Time Data -- PubNub!

  Sources   Download

MIT

The Requires

  • php >=5.3.0

 

The Development Requires

by Dmitry Medvedev
by Victor Kislichenko
by PubNub Support

api ajax realtime push real time real-time

18/03 2015

v3.7.6

3.7.6.0 http://www.pubnub.com/

The Only Global Network For Real-Time Data -- PubNub!

  Sources   Download

MIT

The Requires

  • php >=5.3.0

 

The Development Requires

by Dmitry Medvedev
by Victor Kislichenko
by PubNub Support

api ajax realtime push real time real-time

18/03 2015

v3.7.5

3.7.5.0 http://www.pubnub.com/

The Only Global Network For Real-Time Data -- PubNub!

  Sources   Download

MIT

The Requires

  • php >=5.3.0

 

The Development Requires

by Dmitry Medvedev
by Victor Kislichenko
by PubNub Support

api ajax realtime push real time real-time

13/03 2015

v3.7.4

3.7.4.0 http://www.pubnub.com/

The Only Global Network For Real-Time Data -- PubNub!

  Sources   Download

MIT

The Requires

  • php >=5.3.0

 

The Development Requires

by Dmitry Medvedev
by Victor Kislichenko
by PubNub Support

api ajax realtime push real time real-time

04/03 2015

v3.7.3

3.7.3.0 http://www.pubnub.com/

The Only Global Network For Real-Time Data -- PubNub!

  Sources   Download

MIT

The Requires

  • php >=5.3.0

 

The Development Requires

by Dmitry Medvedev
by Victor Kislichenko
by PubNub Support

api ajax realtime push real time real-time

25/02 2015

v3.7.2

3.7.2.0 http://www.pubnub.com/

The Only Global Network For Real-Time Data -- PubNub!

  Sources   Download

MIT

The Requires

  • php >=5.3.0

 

The Development Requires

by Dmitry Medvedev
by Victor Kislichenko
by PubNub Support

api ajax realtime push real time real-time

06/02 2015

v3.7.1

3.7.1.0 http://www.pubnub.com/

The Only Global Network For Real-Time Data -- PubNub!

  Sources   Download

MIT

The Requires

  • php >=5.3.0

 

The Development Requires

by Dmitry Medvedev
by Victor Kislichenko
by PubNub Support

api ajax realtime push real time real-time

06/01 2015

v3.7.0

3.7.0.0 http://www.pubnub.com/

The Only Global Network For Real-Time Data -- PubNub!

  Sources   Download

MIT

The Requires

  • php >=5.3.0

 

The Development Requires

by Dmitry Medvedev
by Victor Kislichenko
by PubNub Support

api ajax realtime push real time real-time

22/11 2014

v3.6.3

3.6.3.0 http://www.pubnub.com/

The Only Global Network For Real-Time Data -- PubNub!

  Sources   Download

MIT

The Requires

  • php >=5.3.0

 

The Development Requires

by Dmitry Medvedev
by Victor Kislichenko
by PubNub Support

api ajax realtime push real time real-time

28/09 2014

v3.6.2

3.6.2.0 http://www.pubnub.com/

The Only Global Network For Real-Time Data -- PubNub!

  Sources   Download

MIT

The Requires

  • php >=5.3.0

 

The Development Requires

by Dmitry Medvedev
by Victor Kislichenko
by PubNub Support

api ajax realtime push real time real-time

07/08 2014

v3.6.1

3.6.1.0 http://www.pubnub.com/

The Only Global Network For Real-Time Data -- PubNub!

  Sources   Download

MIT

The Requires

  • php >=5.3.0

 

The Development Requires

by Dmitry Medvedev
by Victor Kislichenko
by PubNub Support

api ajax realtime push real time real-time

30/07 2014

v3.6.0

3.6.0.0 http://www.pubnub.com/

The Only Global Network For Real-Time Data -- PubNub!

  Sources   Download

MIT

The Requires

  • php >=5.3.0

 

The Development Requires

by Dmitry Medvedev
by Victor Kislichenko
by PubNub Support

api ajax realtime push real time real-time

04/07 2014

v3.5.4

3.5.4.0 http://www.pubnub.com/

The Only Global Network For Real-Time Data -- PubNub!

  Sources   Download

MIT

The Requires

  • php >=5.3.0

 

The Development Requires

by Dmitry Medvedev
by Victor Kislichenko
by PubNub Support

api ajax realtime push real time real-time

25/06 2014

v3.5.3

3.5.3.0 http://www.pubnub.com/

The Only Global Network For Real-Time Data -- PubNub!

  Sources   Download

MIT

The Requires

  • php >=5.3.0

 

The Development Requires

by Dmitry Medvedev
by Victor Kislichenko
by PubNub Support

api ajax realtime push real time real-time

23/06 2014

v3.5.2

3.5.2.0 http://www.pubnub.com/

The Only Global Network For Real-Time Data -- PubNub!

  Sources   Download

MIT

The Requires

  • php >=5.3.0

 

The Development Requires

by Dmitry Medvedev
by Victor Kislichenko
by PubNub Support

api ajax realtime push real time real-time

14/06 2014

3.5

3.5.0.0 http://www.pubnub.com/

The Only Global Network For Real-Time Data -- PubNub!

  Sources   Download

MIT

The Requires

  • php >=5.3.0

 

The Development Requires

by Dmitry Medvedev
by Victor Kislichenko
by PubNub Support

api ajax realtime push real time real-time