PHP code example of leocavalcante / swoole-irc-client

1. Go to this page and download the library: Download leocavalcante/swoole-irc-client 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/ */

    

leocavalcante / swoole-irc-client example snippets


use SwooleIrc\{HandlerInterface, Reply, Client};

class MyHandler implements HandlerInterface {
    public function onConnect(Client $irc): void {}
    public function onReply(Reply $reply, Client $irc): void {}
}

$irc = Client::withHandler(new MyHandler());
$irc->connect($host, $port);
$irc->start();

use SwooleIrc\{Reply, Client, CallbackHandler};

$handler = static function (Reply $reply): void {};

$irc = Client::withHandler(CallbackHandler::reply($handler))
    ->connect($host, $port)
    ->start();

$irc->pass($password);

$irc->nick($nickname);

$irc->join([$channel]);
$irc->join([$channel], [$key]);

$irc->part([$channel]);

$irc->privmsg([$channel], $text);