PHP code example of matthiasnoback / tail-event-stream
1. Go to this page and download the library: Download matthiasnoback/tail-event-stream 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/ */
matthiasnoback / tail-event-stream example snippets
use TailEventStream\Producer;
$streamFilePath = __DIR__ . '/var/stream.txt';
$producer = new Producer($streamFilePath);
$producer->produce('hello_world', ['Hello' => 'World!']);
use TailEventStream\Consumer;
$streamFilePath = __DIR__ . '/var/stream.txt';
$consumer = new Consumer($streamFilePath);
$consumer->consume(function (string $messageType, array $data) {
// $messageType will be 'hello_world'
// $data will be ['Hello' => 'World!']
});