Download the PHP package huuuk/phalcon-queues without Composer
On this page you can find all versions of the php package huuuk/phalcon-queues. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package phalcon-queues
Advanced Queues for Phalcon PHP Framework
- Instalation
- Configuration
- Drivers
- Usage
- Pushing Jobs
- Worker
- Todo
Instalation
Install via Composer.
Configuration
Settings
First off all you should deside which [driver] suits you best.
Then add appropriate settings in your config.ini
file.
Registering service
Usually it happens in app/config/services.php
file.
Since Phalcon web and console applications has different bootstrap points, you should register queue in your console app bootstrap file too.
How to set up cli application?
You can look over official docs
Also we have an example for you.
Console command
Make QueueTask
class and place it in app/tasks
directory
Don't forget to include this directory in autoloader of your console app
Make sure that you done it properly
Drivers
For now we support only 3 types of drivers:
Null
It's some kind of stub. All jobs pushed to this queue will never be fired.
To use this driver set driver property to null in queue section of your config.ini
file
Synchronus
All jobs pushed to this queue will be fired immediatly.
To use this driver set driver property to sync in queue section of your config.ini
file
Database
All jobs pushed to this queue will be stored in database table. And will be processed by worker.
To use this driver set driver property to database, and database.table in queue section of your config.ini
file
Then you need to create queue table.
Just run queue task
Or you can do it manually by executing SQL query
Usage
Pushing Jobs
You can push job to queue by following code
if you need access to DI instance, just pass it to the closure
NOTE: If you use null or sync driver, DI instance defined in your web application bootstrap file will be passed to the job.
In other cases to thw job will be passed DI instance from your caonsole app.
So it's all up to you to manage services that requires your jobs.
For example in your web app you have Mailer service
and some of your jobs uses it
So to fire job properly, you need to register the same service in your console app DI too.
As all anonymous functions, our "jobs" supports variables from the parent scope.
You can also wrap your job logic in specific class
and push instance of this class to thr queue
Sometimes you need to split your jobs into different queues, for some reasons. You can pass addition parameter to push method.
Also sometimes useful to delay job firing.
Worker
To start working on queue run
For more info run
Todo
- Benstalk driver
- Redis driver