{"id":33988524,"url":"https://github.com/eislambey/php-rsmq","last_synced_at":"2025-12-13T05:57:46.667Z","repository":{"id":39708148,"uuid":"201265696","full_name":"eislambey/php-rsmq","owner":"eislambey","description":"PHP implementation of Redis Simple Message Queue","archived":false,"fork":false,"pushed_at":"2021-06-23T12:48:24.000Z","size":22,"stargazers_count":31,"open_issues_count":4,"forks_count":11,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-11-11T02:49:53.214Z","etag":null,"topics":["message-broker","php","queue","redis","rsmq"],"latest_commit_sha":null,"homepage":null,"language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/eislambey.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-08-08T13:35:15.000Z","updated_at":"2025-05-15T12:16:01.000Z","dependencies_parsed_at":"2022-08-24T01:31:18.620Z","dependency_job_id":null,"html_url":"https://github.com/eislambey/php-rsmq","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/eislambey/php-rsmq","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eislambey%2Fphp-rsmq","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eislambey%2Fphp-rsmq/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eislambey%2Fphp-rsmq/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eislambey%2Fphp-rsmq/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/eislambey","download_url":"https://codeload.github.com/eislambey/php-rsmq/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eislambey%2Fphp-rsmq/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":27701252,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-12-13T02:00:09.769Z","response_time":147,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["message-broker","php","queue","redis","rsmq"],"created_at":"2025-12-13T05:57:46.018Z","updated_at":"2025-12-13T05:57:46.655Z","avatar_url":"https://github.com/eislambey.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Redis Simple Message Queue\n[![Travis CI](https://img.shields.io/travis/eislambey/php-rsmq)](https://travis-ci.org/eislambey/php-rsmq)\n[![Codecov](https://img.shields.io/codecov/c/github/eislambey/php-rsmq)](https://codecov.io/gh/eislambey/php-rsmq)\n\nA lightweight message queue for PHP that requires no dedicated queue server. Just a Redis server.\n\nPHP implementation of [smrchy/rsmq](https://github.com/smrchy/rsmq)\n\n## Installation\n\tcomposer require eislambey/rsmq\n\n## Methods\n\n### Construct\nCreates a new instance of RSMQ.\n\nParameters:\n\n* `$redis` (Redis): *required The Redis instance\n* `$ns` (string): *optional (Default: \"rsmq\")* The namespace prefix used for all keys created by RSMQ\n* `$realtime` (Boolean): *optional (Default: false)* Enable realtime PUBLISH of new messages\n\nExample:\n\n```php\n\u003c?php\n\n$redis = new Redis();\n$redis-\u003econnect('127.0.0.1', 6379);\n$rsmq = new \\Islambey\\RSMQ\\RSMQ($redis);\n```\n\n### Queue\n\n#### createQueue\nCreate a new queue.\n\nParameters:\n\n* `$name` (string): The Queue name. Maximum 160 characters; alphanumeric characters, hyphens (-), and underscores (_) are allowed.\n* `$vt` (int): *optional* *(Default: 30)* The length of time, in seconds, that a message received from a queue will be invisible to other receiving components when they ask to receive messages. Allowed values: 0-9999999 (around 115 days)\n* `$delay` (int): *optional* *(Default: 0)* The time in seconds that the delivery of all new messages in the queue will be delayed. Allowed values: 0-9999999 (around 115 days)\n* `$maxsize` (int): *optional* *(Default: 65536)* The maximum message size in bytes. Allowed values: 1024-65536 and -1 (for unlimited size)\n\nReturns:\n\n* `true` (Bool)\n\nThrows:\n* `\\Islambey\\RSMQ\\Exception`\n\nExample:\n\n```php\n\u003c?php\n\n$rsmq-\u003ecreateQueue('myqueue');\n```\n\n#### listQueues\nList all queues\n\nReturns an array:\n\n* `[\"qname1\", \"qname2\"]`\n\nExample:\n\n```php\n\u003c?php\n\n$queues = $rsmq-\u003elistQueues();\n```\n\n#### deleteQueue\nDeletes a queue and all messages.\n\nParameters:\n\n* `$name` (string): The Queue name.\n\nReturns:\n\n* `true` (Bool)\n\n\nThrows:\n\n* `\\Islambey\\RSMQ\\Exception`\n\nExample:\n\n```php\n\u003c?php\n\n$rsmq-\u003edeleteQueue('myqueue');\n```\n\n#### getQueueAttributes\nGet queue attributes, counter and stats\n\nParameters:\n\n* `$queue` (string): The Queue name.\n\nReturns an associative array:\n\n* `vt` (int): The visibility timeout for the queue in seconds\n* `delay` (int): The delay for new messages in seconds\n* `maxsize` (int): The maximum size of a message in bytes\n* `totalrecv` (int): Total number of messages received from the queue\n* `totalsent` (int): Total number of messages sent to the queue\n* `created` (float): Timestamp (epoch in seconds) when the queue was created\n* `modified` (float): Timestamp (epoch in seconds) when the queue was last modified with `setQueueAttributes`\n* `msgs` (int): Current number of messages in the queue\n* `hiddenmsgs` (int): Current number of hidden / not visible messages. A message can be hidden while \"in flight\" due to a `vt` parameter or when sent with a `delay`\n\nExample:\n\n```php\n\u003c?php\n\n$attributes =  $rsmq-\u003egetQueueAttributes('myqueue');\necho \"visibility timeout: \", $attributes['vt'], \"\\n\";\necho \"delay for new messages: \", $attributes['delay'], \"\\n\";\necho \"max size in bytes: \", $attributes['maxsize'], \"\\n\";\necho \"total received messages: \", $attributes['totalrecv'], \"\\n\";\necho \"total sent messages: \", $attributes['totalsent'], \"\\n\";\necho \"created: \", $attributes['created'], \"\\n\";\necho \"last modified: \", $attributes['modified'], \"\\n\";\necho \"current n of messages: \", $attributes['msgs'], \"\\n\";\necho \"hidden messages: \", $attributes['hiddenmsgs'], \"\\n\";\n```\n\n\n#### setQueueAttributes\nSets queue parameters.\n\nParameters:\n\n* `$queue` (string): The Queue name.\n* `$vt` (int): *optional* * The length of time, in seconds, that a message received from a queue will be invisible to other receiving components when they ask to receive messages. Allowed values: 0-9999999 (around 115 days)\n* `$delay` (int): *optional* The time in seconds that the delivery of all new messages in the queue will be delayed. Allowed values: 0-9999999 (around 115 days)\n* `$maxsize` (int): *optional* The maximum message size in bytes. Allowed values: 1024-65536 and -1 (for unlimited size)\n\nNote: At least one attribute (vt, delay, maxsize) must be supplied. Only attributes that are supplied will be modified.\n\nReturns an associative array:\n\n* `vt` (int): The visibility timeout for the queue in seconds\n* `delay` (int): The delay for new messages in seconds\n* `maxsize` (int): The maximum size of a message in bytes\n* `totalrecv` (int): Total number of messages received from the queue\n* `totalsent` (int): Total number of messages sent to the queue\n* `created` (float): Timestamp (epoch in seconds) when the queue was created\n* `modified` (float): Timestamp (epoch in seconds) when the queue was last modified with `setQueueAttributes`\n* `msgs` (int): Current number of messages in the queue\n* `hiddenmsgs` (int): Current number of hidden / not visible messages. A message can be hidden while \"in flight\" due to a `vt` parameter or when sent with a `delay`\n\nThrows:\n* `\\Islambey\\RSMQ\\Exception`\n\nExample:\n\n```php\n\u003c?php\n\n$queue = 'myqueue';\n$vt = 50;\n$delay = 10;\n$maxsize = 2048;\n$rsmq-\u003esetQueueAttributes($queue, $vt, $delay, $maxsize)\n```\n\n### Messages\n\n#### sendMessage\nSends a new message.\n\nParameters:\n\n* `$queue` (string)\n* `$message` (string)\n* `$delay` (int): *optional* *(Default: queue settings)* The time in seconds that the delivery of the message will be delayed. Allowed values: 0-9999999 (around 115 days)\n\nReturns:\n\n* `$id` (string): The internal message id.\n\nThrows:\n* `\\Islambey\\RSMQ\\Exception`\n\nExample:\n\n```php\n\u003c?php\n\n$id = $rsmq-\u003esendMessage('myqueue', 'a message');\necho \"Message Sent. ID: \", $id;\n```\n\n#### receiveMessage\nReceive the next message from the queue.\n\nParameters:\n\n* `$queue` (string): The Queue name.\n* `$vt` (int): *optional* *(Default: queue settings)* The length of time, in seconds, that the received message will be invisible to others. Allowed values: 0-9999999 (around 115 days)\n\nReturns an associative array:\n\n  * `message` (string): The message's contents.\n  * `id` (string): The internal message id.\n  * `sent` (int): Timestamp of when this message was sent / created.\n  * `fr` (int): Timestamp of when this message was first received.\n  * `rc` (int): Number of times this message was received.\n\nNote: Will return an empty array if no message is there  \n\nThrows:\n* `\\Islambey\\RSMQ\\Exception`\n\nExample:\n\n```php\n\u003c?php\n\n$message = $rsmq-\u003ereceiveMessage('myqueue');\necho \"Message ID: \", $message['id'];\necho \"Message: \", $message['message'];\n```\n\n#### deleteMessage\nParameters:\n\n* `$queue` (string): The Queue name.\n* `$id` (string): message id to delete.\n\nReturns:\n\n* `true` if successful, `false` if the message was not found (bool).\n\nThrows:\n* `\\Islambey\\RSMQ\\Exception`\n\nExample:\n\n```php\n\u003c?php\n\n$id = $rsmq-\u003esendMessage('queue', 'a message');\n$rsmq-\u003edeleteMessage($id);\n```\n\n#### popMessage\nReceive the next message from the queue **and delete it**.\n\n**Important:** This method deletes the message it receives right away. There is no way to receive the message again if something goes wrong while working on the message.\n\nParameters:\n\n* `$queue` (string): The Queue name.\n\nReturns an associvative array:\n\n  * `message` (string): The message's contents.\n  * `id` (string): The internal message id.\n  * `sent` (int): Timestamp of when this message was sent / created.\n  * `fr` (int): Timestamp of when this message was first received.\n  * `rc` (int): Number of times this message was received.\n\nNote: Will return an empty object if no message is there\n\nThrows:\n* `\\Islambey\\RSMQ\\Exception`\n\nExample:\n\n```php\n\u003c?php\n\n$message = $rsmq-\u003epopMessage('myqueue');\necho \"Message ID: \", $message['id'];\necho \"Message: \", $message['message'];\n```\n\n#### changeMessageVisibility\nChange the visibility timer of a single message.\nThe time when the message will be visible again is calculated from the current time (now) + `vt`.\n\nParameters:\n\n* `qname` (string): The Queue name.\n* `id` (string): The message id.\n* `vt` (int): The length of time, in seconds, that this message will not be visible. Allowed values: 0-9999999 (around 115 days)\n\nReturns: \n\n* `true` if successful, `false` if the message was not found (bool).\n\nThrows:\n* `\\Islambey\\RSMQ\\Exception`\n\nExample:\n\n```php\n\u003c?php\n\n$queue = 'myqueue';\n$id = $rsmq-\u003esendMessage($queue, 'a message');\nif($rsmq-\u003echangeMessageVisibility($queue, $id, 60)) {\n\techo \"Message hidden for 60 secs\";\n}\n```\n\n## LICENSE\nThe MIT LICENSE. See [LICENSE](./LICENSE)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Feislambey%2Fphp-rsmq","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Feislambey%2Fphp-rsmq","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Feislambey%2Fphp-rsmq/lists"}