Download the PHP package jellelampaert/ci4_queue without Composer
On this page you can find all versions of the php package jellelampaert/ci4_queue. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download jellelampaert/ci4_queue
More information about jellelampaert/ci4_queue
Files in jellelampaert/ci4_queue
Package ci4_queue
Short Description CodeIgniter4 queuing system
License MIT
Informations about the package ci4_queue
CodeIgniter4 queuing system
Queue tasks that depend on external services (like e-mail) in the database. Process the queue asynchronous (i.e. by using a cronjob), so the user does not have to wait for that service to respond.
Installation
Install the package through Composer.
Run the Composer require command from the Terminal:
composer require jellelampaert/ci4_queue
Once installed, make sure your database is setup correctly and run the migration
php spark migrate -all
Usage
How to load the library
The queuing system has the following methods:
Queue::queue($queue)
Define the queue you want to use. Your application can have different queues, i.e. a queue for e-mails, a queue for webhooks, ...
Queue::add($data)
Add a task to the queue. The argument can be anything: a number, a string, an array, an object, ... Make sure to define a queuename first
Queue::clean($hours)
Delete all tasks from a queue that are processed more than x hours ago.
Queue::cleanAll($hours)
Delete all tasks from all queues that are processed more than x hours ago.
Queue::delete($id)
Delete a task from the database.
Queue::getAllTasks()
Gets all tasks in the queue, whether they are processed or not
Queue::getAllUnprocessed()
Gets all unprocessed tasks from every queue in the database.
Queue::getTask($id)
Gets a task by it's ID
Queue::getUnprocessed()
Get all unprocessed tasks from a queue.
Queue::setProcessed($id)
Sets a task as processed.
Queue::setResponse($id, $data)
Sets the response of a task. This can be used for logging purposes or debugging
License
This package is free software distributed under the terms of the MIT license.