-
-
Notifications
You must be signed in to change notification settings - Fork 49
Expand file tree
/
Copy pathpublish.php
More file actions
18 lines (13 loc) · 556 Bytes
/
Copy pathpublish.php
File metadata and controls
18 lines (13 loc) · 556 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
<?php
// $ php examples/publish.php
// $ REDIS_URI=localhost:6379 php examples/publish.php channel message
require __DIR__ . '/../vendor/autoload.php';
$channel = $argv[1] ?? 'channel';
$message = $argv[2] ?? 'message';
$redis = new Clue\React\Redis\RedisClient(getenv('REDIS_URI') ?: 'localhost:6379');
$redis->publish($channel, $message)->then(function (int $received) {
echo 'Successfully published. Received by ' . $received . PHP_EOL;
}, function (Exception $e) {
echo 'Unable to publish: ' . $e->getMessage() . PHP_EOL;
exit(1);
});