Streaming
📻 Redis Async Streaming for PHP
Install / Use
/learn @laravie/StreamingREADME
Redis Async Streaming for PHP
The project allows you as a developer to listen to Redis pubsub using async instead of blocking I/O using PHP. This is done by utilizing predis/predis-async under the hood.
Installation
To install through composer, simply put the following in your composer.json file:
{
"require": {
"laravie/streaming": "^3.0"
}
}
And then run composer install from the terminal.
Quick Installation
Above installation can also be simplify by using the following command:
composer require "laravie/streaming=^3.0"
Example
<?php
$eventLoop = React\EventLoop\Factory::create();
$chat = new class implements Laravie\Streaming\Listener {
/**
* @return array<int, string>
*/
public function subscribedChannels(): array {
return ['topic:*'];
}
/**
* @param \Predis\Async\Client $redis
* @return void
*/
public function onConnected($redis) {
echo "Connected to redis!";
}
/**
* @param \Predis\Async\Client $redis
* @return void
*/
public function onSubscribed($redis) {
echo "Subscribed to channel `topic:*`!";
}
/**
* Trigger on emitted listener.
*
* @param object $event
* @param object $pubsub
*
* @return void
*/
public function onEmitted($event, $pubsub) {
// PUBLISH topic:laravel "Hello world"
# DESCRIBE $event
#
# {
# "kind": "pmessage",
# "pattern": "topic:*",
# "channel": "topic:laravel",
# "payload": "Hello world"
# }
}
}
$client = new Laravie\Streaming\Client(
['host' => '127.0.0.1', 'port' => 6379], $eventLoop
);
$client->connect($chat);
$eventLoop->run();
Related Skills
node-connect
342.0kDiagnose OpenClaw node connection and pairing failures for Android, iOS, and macOS companion apps
frontend-design
84.7kCreate distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, or applications. Generates creative, polished code that avoids generic AI aesthetics.
openai-whisper-api
342.0kTranscribe audio via OpenAI Audio Transcriptions API (Whisper).
commit-push-pr
84.7kCommit, push, and open a PR
