SelectUpgrading PHP V3 to V4

These docs are for version 3.8.3 of the PHP SDK. To check out the docs for the latest version Click Here.
 

PubNub 4.0 for PHP is our latest and greatest! Please click here for our PubNub 4.0 for PHP docs and SDK.

PubNub 3.x for PHP will encounter End Of Life (EOL) Aug 1st, 2018. All users currently on 3.x should begin migrating to 4.x. The 3.x SDK will continue to work. We will no longer support it and if you run into an issue, we will request that you upgrade to the latest version before solving the issue.

If you have questions about the PubNub for PHP SDK, please contact us at support@pubnub.com.

  • V3 exposes Pubnub
  • V4 exposes PubNub
  • V3 initiates via:
    use Pubnub\Pubnub;
    
    $pubnub = new Pubnub("my_pub_key", "my_sub_key", "my_secret_key", "my_cipher_key", true);
  • V4 initiates via:
    use PubNub\PNConfiguration;
    use PubNub\PubNub;
    
    $pnconf = new PNConfiguration();
    
    $pnconf->setSubscribeKey("my_sub_key");
    $pnconf->setPublishKey("my_pub_key");
    
    $pnconf->setSecretKey("my_secret_key");
    $pnconf->setCipherKey("my_cipher_key");
    $pnconf->setSecure(true);
    
    $pubnub = new PubNub($pnconf);
  • V3:
    $pubnub->publish('my_channel', "Hello World!");
  • V4:
    $pubnub->publish()
        ->channel("my_channel")
        ->message("Hello World!")
        ->sync();
  • V3 exposes only message subscribe callback via method params.
  • V4 exposes the functionality via listeners.
  • V4 returns a status object for each transactional request in the envelope and in the status portion of a listener or a callback.