|
| 1 | +[](https://packagist.org/packages/scienta/php-rsmq-client) |
| 2 | +[](https://packagist.org/packages/syslogic/php-rsmq-client/stats) |
| 3 | +[](https://packagist.org/packages/scienta/php-rsmq-client) |
| 4 | + |
| 5 | + |
1 | 6 | # php-rsmq-client
|
2 |
| -PHP rsmq client |
| 7 | +A library for queueing [RSMQ](https://www.npmjs.com/package/rsmq) messages in [Redis](https://redis.io/). |
| 8 | + |
| 9 | + |
| 10 | +### TL;DR |
| 11 | +A php implementation of the enqueue-code from [RSMQ](https://www.npmjs.com/package/rsmq) for adding messages to the queue. |
| 12 | +Supports [realtime](https://www.npmjs.com/package/rsmq#realtime) PUBLISH of new messages. |
| 13 | + |
| 14 | + |
| 15 | +Installation |
| 16 | +------------ |
| 17 | +The recommended way to install php-rsmq-client is through [Composer](https://getcomposer.org/). |
| 18 | +Add the following dependency to your composer.json |
| 19 | +```json |
| 20 | +{ |
| 21 | + "require": { |
| 22 | + "scienta/php-rsmq-client": "~1.0" |
| 23 | + } |
| 24 | +} |
| 25 | +``` |
| 26 | +Alternatively, you can download the [source code as a file](https://github.com/ScientaNL/php-rsqm-client/releases) and extract it. |
| 27 | + |
| 28 | + |
| 29 | +Usage |
| 30 | +----- |
| 31 | + |
| 32 | +Configuration for queues and messages can be more elaborate than specified below, all [RSMQ](https://www.npmjs.com/package/rsmq) options are supported. |
| 33 | +The library makes use of a Redis adapter make the usage of other php redis clients possible. |
| 34 | +Default (used in this example) is the [phpredis](https://github.com/phpredis/phpredis) C extension. |
| 35 | + |
| 36 | +### Creating a basic queue |
| 37 | +```php |
| 38 | +use Scienta\RSMQClient\Config; |
| 39 | +use Scienta\RSMQClient\Message; |
| 40 | +use Scienta\RSMQClient\Queue; |
| 41 | +use Scienta\RSMQClient\Redis\RedisAdapter; |
| 42 | + |
| 43 | +//Create a redis connection |
| 44 | +$redis = new \Redis(); |
| 45 | +$redis->connect('127.0.0.1', '6379'); |
| 46 | + |
| 47 | +//Configure and create/sync a queue |
| 48 | +$config = new Config('myqueue'); |
| 49 | +$redisAdapter = new RedisAdapter($redis); |
| 50 | +$queue = new Queue($config, $redisAdapter); |
| 51 | + |
| 52 | +//Create a message |
| 53 | +$message = new Message('Hello World'); |
| 54 | + |
| 55 | +//Send the message |
| 56 | +$sentId = $queue->sendMessage($message); |
| 57 | +``` |
0 commit comments