PHPPHP V3 to PHP V4 Migration Guide


These docs are for PubNub 4.x for PHP which is our latest and greatest! For the docs of the older versions of the SDK, please check PubNub 3.x for PHP.

If you have questions about the PubNub for PHP SDK, please contact us at

  • V3 exposes Pubnub
  • V4 exposes PubNub
 Always set the UUID to uniquely identify the user or device that connects to PubNub. This UUID should be persisted, and should remain unchanged for the lifetime of the user or the device. Not setting the UUID can significantly impact your billing if your account uses the Monthly Active Users (MAUs) based pricing model, and can also lead to unexpected behavior if you have Presence enabled.
  • 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();
    $pubnub = new PubNub($pnconf);
  • V3:
    $pubnub->publish('my_channel', "Hello World!");
  • V4:
        ->message("Hello World!")
  • 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.