PHPPHP V4 SDK Troubleshooting 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 support@pubnub.com.

use Monolog\Handler\ErrorLogHandler;
use PubNub\PNConfiguration;
use PubNub\PubNub;

$pnconf = new PNConfiguration();

$pnconf->setPublishKey("pub_key");
$pnconf->setSubscribeKey("sub_key");

$pubnub = new PubNub($pnconf);

$pubnub->getLogger()->pushHandler(new ErrorLogHandler());

You can disable the STDOUT print statements by configuring Monolog to use a different handler. Using Monolog\Handler\NullHandler instead of Monolog\Handler\ErrorLogHandler is the best option.

Using this code sample you can discard all log message output:

use Monolog\Handler\NullHandler;
use PubNub\PNConfiguration;
use PubNub\PubNub;

$pnconf = new PNConfiguration();

$pnconf->setPublishKey("pub_key");
$pnconf->setSubscribeKey("sub_key");

$pubnub = new PubNub($pnconf);

$pubnub->getLogger()->pushHandler(new Nullhandler());