PHP code example of wyrihaximus / react-psr-3-phergie

1. Go to this page and download the library: Download wyrihaximus/react-psr-3-phergie 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/ */

    

wyrihaximus / react-psr-3-phergie example snippets


// Zero create the ReactPHP Event loop (assuming you don't already did)
$loop = Factory::create();

// First create the logger, in this example Monolog is assumed
$logger = new Logger('your app');

// Then create the plugin
$plugin = new PhergiePSR3Plugin('#logs-channel');

// Thirdly set up your logger the way you like
/**
 * Logger set up magic
 */
 
// Fourth add handlers
/**
 * Add any other handlers here, before the fith step, to ensure it 
 * doesn't leak the password 
 */

// Fith wrap the logger in wyrihaximus/psr-3-keyword-filter
$logger = new MessageKeywordFilterLogger(['PASS', 'PRIVMSG'], $logger);

// Sixth create the Phergie Client
$client = new Client();
$client->setLoop($loop);
$client->setLogger($logger); 

// Seventh create the Phergie bot
$bot = new Bot();

// Eighth create the Pergie connection
$connection = new Connection([
    // Your connection config here
]);

// Nineth add the config combining the connection and plugin
$bot->setConfig([
    'plugins' => [
        $loggingPlugin,
        new EventFilterPlugin([ // phergie/phergie-irc-plugin-react-eventfilter
            'filter' => new ConnectionFilter([
                $connection,
            ]),
            'plugins' => [
                new AutoJoinPlugin([ // phergie/phergie-irc-plugin-react-autojoin
                    'channels' => [
                        '#logs-channel',
                    ],
                ]),
            ],
        ]),
    ],
    'connections' => [
        $connection,
    ],
]);

// Tenth set the client and run the bot (note that the false is to ensure this doesn't run the event loop)
$bot->setClient($client);
$bot->run(false);