Manage queues and run jobs

v1.0.0 2018-03-14 19:28 UTC

This package is not auto-updated.

Last update: 2020-07-03 01:09:46 UTC


Queue management in PHP. Purpose of this library is to have basic queue management for common hosting. Cron job, that opens webpage in some interval is what will be enough. Is it possible to set max time limit for running jobs as many hosting services has limited execution time. Main goal was to run tasks in background that needs to run slow.

Useful when you do not have possibility to instal any queue management


Add to project using composer

composer require queues/queue-manager:1.0.0@dev


Create custom job. Just extend \Queue\Job and override run method. Run method returns transformed data.

class LongJob extends \Queue\Job {
    public function run() {
        return $this->getData();

Add Job to queue

When creating instance of QueeuManager, pass context and queue name. Context can be empty or array or some manager.

$newJob = new LongJob()
$queuemanager = new QueueManager($context, $queue);

If you using some kind of framework, e.g. Symfony, you can use dependency injection to get instance of QueueManager.

To execute jobs in queue. Usecase is run this every minute.


If you want to run in loop.


You can set parametters to runner

$maxJobCount - how many jobs will run in one loop $maxJobTime - how long can run one loop cycle. This is useful if you running loop by calling weburl with cron job and page execution has execution time limit. $sleeptime - sleep time when run in loop

$runner = $queuemanager->getRunner($name);

Using context to inject connection.

class MyAppJob extends \Queue\Job {
    public $connection;

    public function init($context=NULL) {

Browsing queues

Queue interface provides methosds to get list of queued Jobs