PHP code example of stanx / monolog-xmpp

1. Go to this page and download the library: Download stanx/monolog-xmpp library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

stanx / monolog-xmpp example snippets




use Fabiang\Xmpp\Client as XmppClient;
use Fabiang\Xmpp\Options as XmppOptions;
use Monolog\Logger;
use Stanx\Monolog\Handler\XmppHandler;

// Create XMPP Client
$options = new XmppOptions('tcp://jabber.host:5222');
$options->setUsername('username')
        ->setPassword('password')
        ->setTimeout(10);
        
$xmpp = new XmppClient($options);

// Create log channel
$log = new Logger('name');

// Add XmppHandler with XmppClient, receivers and log level as parameters
$log->pushHandler(new XmppHandler($xmpp, ['[email protected]'], Logger::WARNING));

// Add records to log
$log->waring('Foo');
$log->error('Bar');