/**
  * @param string $className
  * @param LoopInterface $loop
  * @param array $options
  * @param float $interval
  * @return \React\Promise\PromiseInterface
  * @throws \Exception
  */
 public static function parentFromClass($className, LoopInterface $loop, array $options = [], $interval = self::INTERVAL)
 {
     if (!is_subclass_of($className, 'WyriHaximus\\React\\ChildProcess\\Messenger\\ChildInterface')) {
         throw new \Exception('Given class doesn\'t implement ChildInterface');
     }
     $template = '%s';
     if (isset($options['cmdTemplate'])) {
         $template = $options['cmdTemplate'];
         unset($options['cmdTemplate']);
     }
     $process = new Process(sprintf($template, self::getProcessForCurrentOS() . ' ' . ArgvEncoder::encode($options)));
     return static::parent($process, $loop, $options, $interval)->then(function (Messenger $messenger) use($className) {
         return $messenger->rpc(MessengesFactory::rpc(Factory::PROCESS_REGISTER, ['className' => $className]))->then(function () use($messenger) {
             return \React\Promise\resolve($messenger);
         });
     });
 }
<?php

use React\EventLoop\Factory as LoopFactory;
use WyriHaximus\React\ChildProcess\Messenger\ArgvEncoder;
use WyriHaximus\React\ChildProcess\Messenger\Factory as MessengerFactory;
use WyriHaximus\React\ChildProcess\Messenger\Process;
foreach ([__DIR__ . '/../vendor/autoload.php', __DIR__ . '/../../../autoload.php'] as $file) {
    if (file_exists($file)) {
        require $file;
        break;
    }
}
$arguments = '';
if (isset($argv[1])) {
    $arguments = $argv[1];
}
$loop = LoopFactory::create();
$messenger = MessengerFactory::child($loop, ArgvEncoder::decode($arguments));
Process::create($loop, $messenger);
$loop->run();