PHP code example of cursedcoder / emessenger

1. Go to this page and download the library: Download cursedcoder/emessenger 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/ */

    

cursedcoder / emessenger example snippets




// logserver.php

use React\EventLoop\Factory as EventLoopFactory;
use EMessenger\Transport\UnixTransport;
use EMessenger\MessengerFactory;

$loop = EventLoopFactory::create();

$transport = new UnixTransport($loop, 'unix://tmp/log.sock');
$messenger = MessengerFactory::server($transport);

$messenger->send('debug', 'This is a test message.');




// logwriter.php

use React\EventLoop\Factory as EventLoopFactory;
use EMessenger\Transport\UnixTransport;
use EMessenger\MessengerFactory;

$loop = EventLoopFactory::create();

$transport = new UnixTransport($loop, 'unix://tmp/log.sock');
$messenger = MessengerFactory::client($transport);

$messenger->on('debug', function($debug) {
    echo 'Received debug message: ' . $debug;
});