riorizkyrainey / pubsub-redis-php
Pub/Sub Redis for php
0.1.0
2020-06-19 08:01 UTC
Requires
- php: >=7.2.0
- predis/predis: ^0.8|^1.0|^1.1
Requires (Dev)
- mockery/mockery: ^1.3.1
- phpmd/phpmd: @stable
- phpunit/phpunit: ^8
- squizlabs/php_codesniffer: 3.*
This package is not auto-updated.
Last update: 2024-11-17 00:25:44 UTC
README
Pub/Sub Redis for php
Getting Started
These instructions will get you a copy of the project up and running on your local machine for development and testing purposes. See deployment for notes on how to deploy the project on a live system.
Prerequisites
Before you go make sure you already install Redis.
Installing
Install with composer
composer require riorizkyrainey/pubsub-redis-php
Usage - Subscribe
$client = new Predis\Client([
'scheme' => 'tcp',
'host' => 'redis',
'port' => 6379,
'database' => 0,
'read_write_timeout' => 0,
]);
$redisSubscribeAdapter = new \RioRizkyRainey\PubsubRedis\RedisSubscribeAdapter();
$redisSubscribeAdapter->setClient($client)
->setChannel('channel')
->subscribe(function ($message) {
printf($message . PHP_EOL);
});
Usage - Publisher
$client = new Predis\Client([
'scheme' => 'tcp',
'host' => 'redis',
'port' => 6379,
'database' => 0,
'read_write_timeout' => 0,
]);
$redisPublishAdapter = new \RioRizkyRainey\PubsubRedis\RedisPublishAdapter();
$redisPublishAdapter->setClient($client)
->setChannel('channel');
$redisPublishAdapter->publishMessage('Hi, How do you do?');
$redisPublishAdapter->publishBulkMessage(['Nice to meet you', 'Where are you going?']);
$redisPublishAdapter->publishMessage('I don\'t feel good mr stark');
Built With
- Predis - Flexible and feature-complete Redis client for PHP and HHVM
- PHPUnit - The PHP Unit Testing framework.
- Mockery - Mockery is a simple yet flexible PHP mock object framework for use in unit testing with PHPUnit
Contributing
Please read CONTRIBUTING.md for details on our code of conduct, and the process for submitting pull requests to us.
Versioning
We use SemVer for versioning. For the versions available, see the tags on this repository.
Authors
- Rio Rizky Rainey - Initial work - (https://github.com/RioRizkyRainey)
License
This project is licensed under the MIT License - see the LICENSE.md file for details
Acknowledgments
- Inspired from Superbalist