PHP code example of wyrihaximus / react-child-process-messenger

1. Go to this page and download the library: Download wyrihaximus/react-child-process-messenger 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-child-process-messenger example snippets




use React\EventLoop\LoopInterface;
use WyriHaximus\React\ChildProcess\Messenger\ChildInterface;
use WyriHaximus\React\ChildProcess\Messenger\Messages\Payload;

use function React\Promise\resolve;

final class ExampleChild implements ChildInterface
{
    public static function create(Messenger $messenger, LoopInterface $loop)
    {
        $messenger->registerRpc('example', function (Payload $payload) {
            return resolve($payload->getPayload());
        });
    }
}

MessengerFactory::parentFromClass('ExampleChild', $loop)->then(static function (Messenger $messenger): void {
    $messenger->rpc(/* etc etc */);
});