PHP code example of webit / message-bus-sf-process
1. Go to this page and download the library: Download webit/message-bus-sf-process 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/ */
webit / message-bus-sf-process example snippets
use Webit\MessageBus\Message;
use Symfony\Component\Process\Process;
class MyProcessFactory implements ProcessFactory
{
/**
* @inheritdoc
*/
public function create(Message $message)
{
return new Process(
sprintf(
'/usr/local/my-binary.php %s %s',
escapeshellarg($message->type()),
escapeshellarg($message->content())
)
);
}
}
use Webit\MessageBus\Infrastructure\Symfony\Process\Launcher\SynchronousProcessLauncher;
$myFactory = new MyProcessFactory();
$launcher = new SynchronousProcessLauncher($myFactory);
use Webit\MessageBus\Infrastructure\Symfony\Process\Launcher\ParallelProcessManager;
use Webit\MessageBus\Infrastructure\Symfony\Process\Launcher\AsynchronousProcessLauncher;
$myFactory = new MyProcessFactory();
$launcher = new AsynchronousProcessLauncher(
$myFactory,
new ParallelProcessManager($maxParallelProcessNumber = 5) // to run at most 5 parallel processes
);
use Webit\MessageBus\Infrastructure\Symfony\Process\ProcessPublisher;
use Webit\MessageBus\Message;
$publisher = new ProcessPublisher($launcher);
$publisher->publish(new Message('type', 'content'));
use Webit\MessageBus\Infrastructure\Symfony\Process\ProcessConsumer;
use Webit\MessageBus\Message;
$consumer = new ProcessConsumer($launcher);
$consumer->consume(new Message('type', 'content'));
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.