{"id":21467399,"url":"https://github.com/elusivecodes/fyrequeue","last_synced_at":"2025-08-03T21:40:13.345Z","repository":{"id":57703062,"uuid":"501194299","full_name":"elusivecodes/FyreQueue","owner":"elusivecodes","description":"FyreQueue is a free, open-source queue library for PHP.","archived":false,"fork":false,"pushed_at":"2024-11-17T00:55:37.000Z","size":119,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-11-17T01:47:53.434Z","etag":null,"topics":["php","queue","redis","worker"],"latest_commit_sha":null,"homepage":"","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/elusivecodes.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-06-08T10:01:49.000Z","updated_at":"2024-11-17T00:55:20.000Z","dependencies_parsed_at":"2024-06-01T17:24:03.580Z","dependency_job_id":"48556889-d081-4f72-ab7f-431a0fcb814f","html_url":"https://github.com/elusivecodes/FyreQueue","commit_stats":{"total_commits":2,"total_committers":1,"mean_commits":2.0,"dds":0.0,"last_synced_commit":"08a9927b91b8d3ec2cb5c6ecb48f29e368367998"},"previous_names":[],"tags_count":16,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/elusivecodes%2FFyreQueue","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/elusivecodes%2FFyreQueue/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/elusivecodes%2FFyreQueue/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/elusivecodes%2FFyreQueue/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/elusivecodes","download_url":"https://codeload.github.com/elusivecodes/FyreQueue/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":226017461,"owners_count":17560514,"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","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":["php","queue","redis","worker"],"created_at":"2024-11-23T08:17:52.587Z","updated_at":"2025-07-15T05:31:25.601Z","avatar_url":"https://github.com/elusivecodes.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# FyreQueue\r\n\r\n**FyreQueue** is a free, open-source queue library for *PHP*.\r\n\r\n\r\n## Table Of Contents\r\n- [Installation](#installation)\r\n- [Basic Usage](#basic-usage)\r\n- [Methods](#methods)\r\n- [Queues](#queues)\r\n    - [Redis](#redis)\r\n- [Workers](#workers)\r\n- [Messages](#messages)\r\n- [Commands](#commands)\r\n    - [Stats](#stats)\r\n    - [Worker](#worker)\r\n\r\n\r\n\r\n## Installation\r\n\r\n**Using Composer**\r\n\r\n```\r\ncomposer require fyre/queue\r\n```\r\n\r\nIn PHP:\r\n\r\n```php\r\nuse Fyre\\Queue\\QueueManager;\r\n```\r\n\r\n## Basic Usage\r\n\r\n- `$container` is a [*Container*](https://github.com/elusivecodes/FyreContainer).\r\n- `$config` is a [*Config*](https://github.com/elusivecodes/FyreConfig).\r\n\r\n```php\r\n$queueManager = new QueueManager($container, $config);\r\n```\r\n\r\nDefault configuration options will be resolved from the \"*Queue*\" key in the [*Config*](https://github.com/elusivecodes/FyreConfig).\r\n\r\n**Autoloading**\r\n\r\nIt is recommended to bind the *QueueManager* to the [*Container*](https://github.com/elusivecodes/FyreContainer) as a singleton.\r\n\r\n```php\r\n$container-\u003esingleton(QueueManager::class);\r\n```\r\n\r\nAny dependencies will be injected automatically when loading from the [*Container*](https://github.com/elusivecodes/FyreContainer).\r\n\r\n```php\r\n$queueManager = $container-\u003euse(QueueManager::class);\r\n```\r\n\r\n\r\n## Methods\r\n\r\n**Build**\r\n\r\nBuild a [*Queue*](#queues).\r\n\r\n- `$options` is an array containing configuration options.\r\n\r\n```php\r\n$queue = $queueManager-\u003ebuild($options);\r\n```\r\n\r\n[*Queue*](#queues) dependencies will be resolved automatically from the [*Container*](https://github.com/elusivecodes/FyreContainer).\r\n\r\n**Clear**\r\n\r\nClear all instances and configs.\r\n\r\n```php\r\n$queueManager-\u003eclear();\r\n```\r\n\r\n**Get Config**\r\n\r\nSet a [*Queue*](#queues) config.\r\n\r\n- `$key` is a string representing the [*Queue*](#queues) key.\r\n\r\n```php\r\n$config = $queueManager-\u003egetConfig($key);\r\n```\r\n\r\nAlternatively, if the `$key` argument is omitted an array containing all configurations will be returned.\r\n\r\n```php\r\n$config = $queueManager-\u003egetConfig();\r\n```\r\n\r\n**Has Config**\r\n\r\nDetermine whether a [*Queue*](#queues) config exists.\r\n\r\n- `$key` is a string representing the [*Queue*](#queues) key, and will default to `QueueManager::DEFAULT`.\r\n\r\n```php\r\n$hasConfig = $queueManager-\u003ehasConfig($key);\r\n```\r\n\r\n**Is Loaded**\r\n\r\nDetermine whether a [*Queue*](#queues) instance is loaded.\r\n\r\n- `$key` is a string representing the [*Queue*](#queues) key, and will default to `QueueManager::DEFAULT`.\r\n\r\n```php\r\n$isLoaded = $queueManager-\u003eisLoaded($key);\r\n```\r\n\r\n**Push**\r\n\r\nPush a job to a [*Queue*](#queues).\r\n\r\n- `$className` is a string representing the job class.\r\n- `$arguments` is an array containing arguments that will be passed to the job.\r\n- `$options` is an array containing options for the [*Message*](#messages).\r\n    - `config` is a string representing the configuration key, and will default to `QueueManager::DEFAULT`.\r\n    - `queue` is a string representing the [queue](#queues) name, and will default to `QueueManager::DEFAULT`.\r\n    - `method` is a string representing the class method, and will default to \"*run*\".\r\n    - `delay` is a number representing the number of seconds before the job should run, and will default to *0*.\r\n    - `expires` is a number representing the number of seconds after which the job will expire, and will default to *0*.\r\n    - `retry` is a boolean indicating whether the job should be retried if it fails, and will default to *true*.\r\n    - `maxRetries` is a number indicating the maximum number of times the job should be retried, and will default to *5*.\r\n    - `unique` is a boolean indicating whether the job should be unique, and will default to *false*.\r\n\r\n```php\r\n$queueManager-\u003epush($className, $arguments, $options);\r\n```\r\n\r\nJob dependencies will be resolved automatically from the [*Container*](https://github.com/elusivecodes/FyreContainer).\r\n\r\n**Set Config**\r\n\r\nSet the [*Queue*](#queues) config.\r\n\r\n- `$key` is a string representing the [*Queue*](#queues) key.\r\n- `$options` is an array containing configuration options.\r\n\r\n```php\r\n$queueManager-\u003esetConfig($key, $options);\r\n```\r\n\r\n**Unload**\r\n\r\nUnload a [*Queue*](#queues).\r\n\r\n- `$key` is a string representing the [*Queue*](#queues) key, and will default to `QueueManager::DEFAULT`.\r\n\r\n```php\r\n$queueManager-\u003eunload($key);\r\n```\r\n\r\n**Use**\r\n\r\nLoad a shared [*Queue*](#queues) instance.\r\n\r\n- `$key` is a string representing the [*Queue*](#queues) key, and will default to *\"default\"*.\r\n\r\n```php\r\n$queue = $queueManager-\u003euse($key);\r\n```\r\n\r\n[*Queue*](#queues) dependencies will be resolved automatically from the [*Container*](https://github.com/elusivecodes/FyreContainer).\r\n\r\n\r\n## Queues\r\n\r\nYou can load a specific queue by specifying the `className` option of the `$options` variable above.\r\n\r\nCustom queues can be created by extending `\\Fyre\\Queue\\Queue`, ensuring all below methods are implemented.\r\n\r\n**Clear**\r\n\r\nClear all items from the queue.\r\n\r\n- `$queueName` is a string representing the queue name, and will default to `QueueManager::DEFAULT`.\r\n\r\n```php\r\n$queue-\u003eclear($queueName);\r\n```\r\n\r\n**Complete**\r\n\r\nMark a job as completed.\r\n\r\n- `$message` is a [*Message*](#message).\r\n\r\n```php\r\n$queue-\u003ecomplete($message);\r\n```\r\n\r\n**Fail**\r\n\r\nMark a job as failed.\r\n\r\n- `$message` is a [*Message*](#message).\r\n\r\n```php\r\n$queue-\u003efail($message);\r\n```\r\n\r\n**Pop**\r\n\r\nPop the last item off the queue.\r\n\r\n- `$queueName` is a string representing the queue name.\r\n\r\n```php\r\n$message = $queue-\u003epop($queueName);\r\n```\r\n\r\n**Push**\r\n\r\nPush a job onto the queue.\r\n\r\n- `$message` is a [*Message*](#message).\r\n\r\n```php\r\n$queue-\u003epush($message);\r\n```\r\n\r\n**Queues**\r\n\r\nGet all the active queues.\r\n\r\n```php\r\n$queues = $queue-\u003equeues();\r\n```\r\n\r\n**Reset**\r\n\r\nReset the queue statistics.\r\n\r\n- `$queueName` is a string representing the queue name, and will default to `QueueManager::DEFAULT`.\r\n\r\n```php\r\n$queue-\u003ereset($queueName);\r\n```\r\n\r\n**Stats**\r\n\r\nGet the statistics for a queue.\r\n\r\n- `$queueName` is a string representing the queue name, and will default to `QueueManager::DEFAULT`.\r\n\r\n```php\r\n$stats = $queue-\u003estats($queueName);\r\n```\r\n\r\n\r\n### Redis\r\n\r\nThe Redis queue can be loaded using custom configuration.\r\n\r\n- `$options` is an array containing configuration options.\r\n    - `className` must be set to `\\Fyre\\Queue\\Handlers\\RedisQueue`.\r\n    - `host` is a string representing the Redis host, and will default to \"*127.0.0.1*\".\r\n    - `password` is a string representing the Redis password\r\n    - `port` is a number indicating the Redis port, and will default to *6379*.\r\n    - `database` is a string representing the Redis database.\r\n    - `timeout` is a number indicating the connection timeout.\r\n    - `persist` is a boolean indicating whether to use a persistent connection, and will default to *true*.\r\n    - `tls` is a boolean indicating whether to use a tls connection, and will default to *true*.\r\n    - `ssl` is an array containing SSL options.\r\n        - `key` is a string representing the path to the key file.\r\n        - `cert` is a string representing the path to the certificate file.\r\n        - `ca` is a string representing the path to the certificate authority file.\r\n\r\n```php\r\n$container-\u003euse(Config::class)-\u003eset('Queue.redis', $options);\r\n```\r\n\r\n\r\n## Workers\r\n\r\nWorkers are long running tasks that will consume and execute jobs from the queue.\r\n\r\n```php\r\nuse Fyre\\Queue\\Worker;\r\n```\r\n\r\n- `$container` is a [*Container*](https://github.com/elusivecodes/FyreContainer).\r\n- `$queueManager` is a *QueueManager*.\r\n- `$eventManager` is an [*EventManager*](https://github.com/elusivecodes/FyreEvent).\r\n- `$options` is an array containing configuration options.\r\n    - `config` is a string representing the configuration key, and will default to `QueueManager::DEFAULT`.\r\n    - `queue` is a string representing the queue name, and will default to `QueueManager::DEFAULT`.\r\n    - `maxJobs` is a number representing the maximum number of jobs to execute, and will default to *0*.\r\n    - `maxRuntime` is a number representing the maximum number of seconds the worker should run, and will default to *0*.\r\n    - `rest` is a number representing the number of microseconds to rest after processing a job, and will default to *10000*.\r\n    - `sleep` is a number representing the number of microseconds to sleep if no jobs are in the queue, and will default to *100000*.\r\n\r\n```php\r\n$worker = new Worker($container, $queueManager, $eventManager, $options);\r\n```\r\n\r\n**Run**\r\n\r\nRun the worker.\r\n\r\n```php\r\n$worker-\u003erun();\r\n```\r\n\r\n\r\n## Messages\r\n\r\nMessages are used internally to pass data between the [*Queue*](#queues) and [*Worker*](#workers).\r\n\r\n```php\r\nuse Fyre\\Queue\\Message;\r\n```\r\n\r\n- `$options` is an array containing options for the message.\r\n    - `className` is a string representing the job class.\r\n    - `arguments` is an array containing arguments that will be passed to the job.\r\n    - `config` is a string representing the configuration key, and will default to `QueueManager::DEFAULT`.\r\n    - `queue` is a string representing the queue name, and will default to `QueueManager::DEFAULT`.\r\n    - `method` is a string representing the class method, and will default to \"*run*\".\r\n    - `delay` is a number representing the number of seconds before the job should run, and will default to *0*.\r\n    - `expires` is a number representing the number of seconds after which the job will expire, and will default to *0*.\r\n    - `retry` is a boolean indicating whether the job should be retried if it fails, and will default to *true*.\r\n    - `maxRetries` is a number indicating the maximum number of times the job should be retried, and will default to *5*.\r\n    - `unique` is a boolean indicating whether the job should be unique, and will default to *false*.\r\n\r\n```php\r\n$message = new Message($options);\r\n```\r\n\r\n**Get After**\r\n\r\nGet the timestamp when the message can be sent.\r\n\r\n```php\r\n$after = $message-\u003egetTimestamp();\r\n```\r\n\r\n**Get Config**\r\n\r\nGet the message config.\r\n\r\n```php\r\n$config = $message-\u003egetConfig();\r\n```\r\n\r\n**Get Hash**\r\n\r\nGet the message hash.\r\n\r\n```php\r\n$hash = $message-\u003egetHash();\r\n```\r\n\r\n**Get Queue**\r\n\r\nGet the message queue.\r\n\r\n```php\r\n$queueName = $message-\u003egetQueue();\r\n```\r\n\r\n**Is Expired**\r\n\r\nDetermine whether the message has expired.\r\n\r\n```php\r\n$isExpired = $message-\u003eisExpired();\r\n```\r\n\r\n**Is Ready**\r\n\r\nDetermine whether the message is ready.\r\n\r\n```php\r\n$isReady = $message-\u003eisReady();\r\n```\r\n\r\n**Is Unique**\r\n\r\nDetermine whether the message is unique.\r\n\r\n```php\r\n$isUnique = $message-\u003eisUnique();\r\n```\r\n\r\n**Is Valid**\r\n\r\nDetermine whether the message is valid.\r\n\r\n```php\r\n$isValid = $message-\u003eisValid();\r\n```\r\n\r\n**Should Retry**\r\n\r\nDetermine whether the message should be retried.\r\n\r\n```php\r\n$shouldretry = $message-\u003eshouldRetry();\r\n```\r\n\r\n\r\n## Commands\r\n\r\n### Stats\r\n\r\nDisplay stats for the queue.\r\n\r\n- `--config` is a the configuration key, and will default to `QueueManager::DEFAULT`.\r\n- `--queue` is a the [queue](#queues) name, and will default to `QueueManager::DEFAULT`.\r\n\r\n```php\r\n$commandRunner-\u003erun('queue:stats', ['--config', 'default', '--queue', 'default']);\r\n```\r\n\r\n### Worker\r\n\r\nStart a background queue worker.\r\n\r\n- `--config` is a the configuration key, and will default to `QueueManager::DEFAULT`.\r\n- `--queue` is a the [queue](#queues) name, and will default to `QueueManager::DEFAULT`.\r\n- `--max-jobs` is the maximum number of jobs to execute, and will default to *0*.\r\n- `--max-runtime` is the maximum number of seconds the worker should run, and will default to *0*.\r\n\r\n```php\r\n$commandRunner-\u003erun('queue:worker', ['--config', 'default', '--queue', 'default', '--max-jobs', '99', '--max-runtime', '60']);\r\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Felusivecodes%2Ffyrequeue","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Felusivecodes%2Ffyrequeue","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Felusivecodes%2Ffyrequeue/lists"}