2017 © Pedro PelĆ”ez
 

library queue

Zend Framework module that integrates with various queue management systems

image

slm/queue

Zend Framework module that integrates with various queue management systems

  • Friday, January 5, 2018
  • by bushbaby
  • Repository
  • 13 Watchers
  • 125 Stars
  • 168,908 Installations
  • PHP
  • 8 Dependents
  • 1 Suggesters
  • 42 Forks
  • 13 Open issues
  • 31 Versions
  • 7 % Grown

The README.md

SlmQueue

Important notice

We decided to move onto Symfony Messenger and we are therefore not maintaining this repository anymore. Feel free to fork it and make it your own., (*1)

Latest Stable Version, (*2)

SlmQueue is a job queue abstraction layer for Laminas (formerly Zend Framework) and Mezzio (formerly Zend Expressive) applications. It supports various job queue systems and makes your application independent from the underlying system you use. The currently supported systems have each their own adapter library:, (*3)

When to use

A job queue helps to offload long or memory-intensive processes from the HTTP requests clients sent to the Laminas application. This will make your response times shorter and your visitors happier. There are many use cases for asynchronous jobs and a few examples are:, (*4)

  1. Send an email
  2. Create a PDF file
  3. Connect to a third party server over HTTP

In all cases you want to serve the response as soon as possible to your visitor, without letting them wait for this long process. SlmQueue enables you to implement a job queue system very easily within your existing application., (*5)

Installation

SlmQueue works with Composer. Make sure you have the composer.phar downloaded and you have a composer.json file at the root of your project. To install it, add the following line into your composer.json file:, (*6)

"require": {
    "slm/queue": "^3.0"
}

After installation of the package, you need to complete the following steps to use SlmQueue:, (*7)

  1. Enable the module by adding SlmQueue in your application.config.php file.
  2. Copy the slm_queue.global.php.dist (you can find this file in the config folder of SlmQueue) into your config/autoload folder and apply any setting you want.

NB. SlmQueue is a skeleton and therefore useless by itself. Enable an adapter to give you the implementation details you need to push jobs into the queue. Install one of the available adapters (SlmQueueDoctrine, SlmQueueRabbitMq, or SlmQueueSqs)., (*8)

Requirements

Code samples

Below are a few snippets which show the power of SlmQueue in your application. The full documentation is available in docs/ directory., (*9)

A sample job to send an email with php's mail() might look like this:, (*10)

namespace MyModule\Job;

use SlmQueue\Job\AbstractJob;

class EmailJob extends AbstractJob
{
    public static function create(string $to, string $subject, string $message): self
    {
        // This will bypass the constructor, and thus load a job without
        // having to load the dependencies.
        $job = self::createEmptyJob([
            'subject' => $subject,
            'to' => $to,
            'message' => $message,
        ]);

        // Add some metadata, so we see what is going on.
        $job->setMetadata('to', $to);

        return $job;
    }

    private SomeMailService $mailService;

    public function __construct(SomeMailService $mailService)
    {
        $this->mailService = $mailService;
    }

    public function execute()
    {
        $payload = $this->getContent();

        $to      = $payload['to'];
        $subject = $payload['subject'];
        $message = $payload['message'];

        $this->mailService->send($to, $subject, $message);
    }
}

If you want to inject this job into a queue, you can do this for instance in your controller:, (*11)

namespace MyModule\Controller;

use MyModule\Job\Email as EmailJob;
use SlmQueue\Queue\QueueInterface;
use Laminas\Mvc\Controller\AbstractActionController;

class MyController extends AbstractActionController
{
    protected $queue;

    public function __construct(QueueInterface $queue)
    {
        $this->queue = $queue;
    }

    public function fooAction()
    {
        // Do some work

        $this->queue->push(
            EmailJob::create('john@doe.com', 'Just hi', 'Hi, I want to say hi!'),
            ['delay' => 60]
        );
    }
}

Now the above code lets you insert jobs in a queue, but then you need to spin up a worker which can process these jobs., (*12)

SlmQueue integrates with laminas-cli for command line usage. You can start up a worker for queue "default" with the following command:, (*13)

$ vendor/bin/laminas slm-queue:start default

Contributing

SlmQueue is developed by various fanatic Laminas users. The code is written to be as generic as possible for Laminas applications. If you want to contribute to SlmQueue, fork this repository and start hacking!, (*14)

Any bugs can be reported as an issue at GitHub. If you want to contribute, please be aware of the following guidelines:, (*15)

  1. Fork the project to your own repository
  2. Use branches to work on your own part
  3. Create a Pull Request at the canonical SlmQueue repository
  4. Make sure to cover changes with the right amount of unit tests
  5. If you add a new feature, please work on some documentation as well

For long-term contributors, push access to this repository is granted., (*16)

Who to thank?

Jurian Sluiman and Michaƫl Gallego did the initial work on creating this repo, and maintained it for a long time., (*17)

Currently it is maintained by:, (*18)

The Versions

17/12 2015

0.5.1

0.5.1.0 https://github.com/juriansluiman/SlmQueue

Zend Framework 2 module that integrates with various queue management systems

  Sources   Download

BSD-3-Clause

The Requires

 

The Development Requires

zf2 queue job

10/08 2015

0.5.0

0.5.0.0 https://github.com/juriansluiman/SlmQueue

Zend Framework 2 module that integrates with various queue management systems

  Sources   Download

BSD-3-Clause

The Requires

 

The Development Requires

zf2 queue job

02/03 2015

0.4.2

0.4.2.0 https://github.com/juriansluiman/SlmQueue

Zend Framework 2 module that integrates with various queue management systems

  Sources   Download

BSD-3-Clause

The Requires

 

The Development Requires

zf2 queue job

17/01 2015

0.4.1

0.4.1.0 https://github.com/juriansluiman/SlmQueue

Zend Framework 2 module that integrates with various queue management systems

  Sources   Download

BSD-3-Clause

The Requires

 

The Development Requires

zf2 queue job

13/10 2014

0.4.0

0.4.0.0 https://github.com/juriansluiman/SlmQueue

Zend Framework 2 module that integrates with various queue management systems

  Sources   Download

BSD-3-Clause

The Requires

 

The Development Requires

zf2 queue job

09/10 2014

0.4.0-beta3

0.4.0.0-beta3 https://github.com/juriansluiman/SlmQueue

Zend Framework 2 module that integrates with various queue management systems

  Sources   Download

BSD-3-Clause

The Requires

 

The Development Requires

zf2 queue job

09/10 2014

dev-id

dev-id https://github.com/juriansluiman/SlmQueue

Zend Framework 2 module that integrates with various queue management systems

  Sources   Download

BSD-3-Clause

The Requires

 

The Development Requires

zf2 queue job

08/10 2014

dev-correct-count

dev-correct-count https://github.com/juriansluiman/SlmQueue

Zend Framework 2 module that integrates with various queue management systems

  Sources   Download

BSD-3-Clause

The Requires

 

The Development Requires

zf2 queue job

06/10 2014

0.4.0-beta2

0.4.0.0-beta2 https://github.com/juriansluiman/SlmQueue

Zend Framework 2 module that integrates with various queue management systems

  Sources   Download

BSD-3-Clause

The Requires

 

The Development Requires

zf2 queue job

02/10 2014

0.4.0-beta1

0.4.0.0-beta1 https://github.com/juriansluiman/SlmQueue

Zend Framework 2 module that integrates with various queue management systems

  Sources   Download

BSD-3-Clause

The Requires

 

The Development Requires

zf2 queue job

08/08 2014

dev-feature/simplified-listeners

dev-feature/simplified-listeners https://github.com/juriansluiman/SlmQueue

Zend Framework 2 module that integrates with various queue management systems

  Sources   Download

BSD-3-Clause

The Requires

 

The Development Requires

zf2 queue job

30/03 2014

0.3.0

0.3.0.0 https://github.com/juriansluiman/SlmQueue

Zend Framework 2 module that integrates with various queue management systems

  Sources   Download

BSD-3-Clause

The Requires

 

The Development Requires

zf2 queue job

26/03 2014

0.3.0-rc1

0.3.0.0-RC1 https://github.com/juriansluiman/SlmQueue

Zend Framework 2 module that integrates with various queue management systems

  Sources   Download

BSD-3-Clause

The Requires

 

The Development Requires

zf2 queue job

23/02 2014

0.3.0-beta3

0.3.0.0-beta3 https://github.com/juriansluiman/SlmQueue

Zend Framework 2 module that integrates with various queue management systems

  Sources   Download

BSD-3-Clause

The Requires

 

The Development Requires

zf2 queue job

23/01 2014

0.3.0-beta2

0.3.0.0-beta2 https://github.com/juriansluiman/SlmQueue

Zend Framework 2 module that integrates with various queue management systems

  Sources   Download

BSD-3-Clause

The Requires

 

The Development Requires

zf2 queue job

09/01 2014

0.3.0-beta1

0.3.0.0-beta1 https://github.com/juriansluiman/SlmQueue

Zend Framework 2 module that integrates with various queue management systems

  Sources   Download

The Requires

 

The Development Requires

zf2 queue job

14/03 2013

0.2.5

0.2.5.0 https://github.com/juriansluiman/SlmQueue

Zend Framework 2 module that integrates with various queue management systems

  Sources   Download

The Requires

 

The Development Requires

zf2 queue job

26/02 2013

0.2.4

0.2.4.0 https://github.com/juriansluiman/SlmQueue

Zend Framework 2 module that integrates with various queue management systems

  Sources   Download

The Requires

 

The Development Requires

zf2 queue job

18/02 2013

0.2.3

0.2.3.0 https://github.com/juriansluiman/SlmQueue

Zend Framework 2 module that integrates with various queue management systems

  Sources   Download

The Requires

 

zf2 queue job

14/02 2013

0.2.2

0.2.2.0 https://github.com/juriansluiman/SlmQueue

Zend Framework 2 module that integrates with various queue management systems

  Sources   Download

The Requires

 

zf2 queue job

12/02 2013

0.2.1

0.2.1.0 https://github.com/juriansluiman/SlmQueue

Zend Framework 2 module that integrates with various queue management systems

  Sources   Download

The Requires

 

zf2 queue job

09/02 2013

0.2

0.2.0.0 https://github.com/juriansluiman/SlmQueue

Zend Framework 2 module that integrates with various queue management systems

  Sources   Download

The Requires

 

zf2 queue job