Redis Pub/Sub
Minimal sample for Redis Pub/Sub functionality using Predis - PHP Redis client
Instructions
Setup
- Install dependencies using
composer install
- Install
redis-server
- [optional] Install
redis-tools
, to getredis-cli
- Start Redis server with default parameters ( no password, port
6379
) - [optional] Can run
redis-cli
and executemonitor
command to see what's happening
Usage
- Run
php sub.php
to subscribe to "main-channel" channel and see messages sent to this channel - Run
php pub.php
to send hardcoded message - Run
php unsub.php
to unsubscribe from channel ( will close also sub.php process)
Source
Instructions were taken from http://squizzle.me/php/predis/doc/#pub