Minimal sample for Redis Pub/Sub functionality using Predis - PHP Redis client
- 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
- 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)
Instructions were taken from http://squizzle.me/php/predis/doc/#pub