Download the PHP package folded/queue without Composer
On this page you can find all versions of the php package folded/queue. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package queue
folded/history
Queue job management for your web app.
Summary
- About
- Features
- Requirements
- Installation
- Examples
- Version support
About
I created this library to be able to easily create jobs to enqueue and retrieve in a later time. I use it for tasks that I don't want to block on my PHP requests (like sending an email after an account has been created, which I can send later).
Folded is a constellation of packages to help you setting up a web app easily, using ready to plug in packages.
- folded/action: A way to organize your controllers for your web app.
- folded/config: Configuration utilities for your PHP web app.
- folded/crypt: Encrypt and decrypt strings for your web app.
- folded/exception: Various kind of exception to throw for your web app.
- folded/file: Manipulate files with functions for your web app.
- folded/history: Manipulate the browser history for your web app.
- folded/http: HTTP utilities for your web app.
- folded/orm: An ORM for you web app.
- folded/routing: Routing functions for your PHP web app.
- folded/request: Request utilities, including a request validator, for your PHP web app.
- folded/session: Session functions for your web app.
- folded/view: View utilities for your PHP web app.
Features
- Can add jobs to a queue
- Can retrieve jobs from a queue
- Can check if there is jobs to process in a queue
- Can set the queue driver
- file
- Can set the type of job retreival
- FIFO: First In, First Out
- FILO: First In, Last Out
Requirements
- PHP version >= 7.4.0
- Composer installed
Installation
- 1. Install the package
- 2. Add the bootstrap code
1. Install the package
In your root folder, run this command:
2. Add the bootstrap code
As early as possible, and by making sure the code is ran before add or get jobs in a queue:
Check the examples for a complete list of drivers and type of queue, as well as constants to avoid writting the queue drivers and type by hand.
Examples
- 1. Add a job to a queue
- 2. Get a job from a queue
- 3. Check if there is a job to process from a queue
- 4. Set the queue driver
- 5. Set the queue type
1. Add a job to a queue
In this example, we will add a job to a queue.
If you used the "file" driver, you will see a new default.job
file containing your job.
If you want to organize in multiple queue identified by a special name, use the third parameter:
If you use the "file" driver, you will see a new emails.job
file named after the name of your queue, and containing your job.
2. Get a job from a queue
In this example, we will get the first job in our queue.
As you can see, you will get an instance of Folded\QueueJob
when getting the job quuee.
By default, you retreive jobs from the "default" queue. If you use the "file" driver, the job is taken from the "default.job" queue file.
When a job is taken, it is removed from the queue.
If you need to get a job from a named queue, use the first parameter:
For instance, if you use the "file" driver, this will take the job from the "emails.job" queue file.
3. Check if there is a job to process from a queue
In this example, we will check if there is a job to process from a queue.
By default, this method will check if a job is available from the default queue. if you need to check from a named queue, use the first parameter:
4. Set the queue driver
In this example, we will set the queue driver.
Here is a list of supported queue drivers:
- file
If you do not want to write the queue driver by hand, you can use constants instead:
Here is a list of available constants:
QUEUE_DRIVER_FILE
5. Set the queue type
In this example, we will set the kind of job retreival.
Here is a list of supported queue types:
fifo
: First In, First Outfilo
: First In, Last Out
If you do not want to write the queue type by hand, you can use constants instead:
QUEUE_TYPE_FIFO
QUEUE_TYPE_FILO
So the previous code snippet becomes:
Version support
7.3 | 7.4 | 8.0 | |
---|---|---|---|
v0.1.0 | ❌ | ✔️ | ❓ |
All versions of queue with dependencies
webmozart/assert Version 1.*
doctrine/dbal Version 2.*
folded/file Version 0.2.*