All Projects β†’ Webador β†’ SlmQueue

Webador / SlmQueue

Licence: other
Laminas / Mezzio module that integrates with various queue management systems.

Programming Languages

PHP
23972 projects - #3 most used programming language
shell
77523 projects

Projects that are alternatives of or similar to SlmQueue

ErrorHeroModule
πŸ’Ž A Hero for your Zend Framework/Laminas, and Expressive/Mezzio application to log ( DB and Mail ) and handle php errors & exceptions during Mvc process/between request and response
Stars: ✭ 47 (-65.19%)
Mutual labels:  laminas, mezzio
laminas-dependency-plugin
Replace zendframework and zfcampus packages with their Laminas Project equivalents.
Stars: ✭ 32 (-76.3%)
Mutual labels:  laminas, mezzio
zend-di-config
PSR-11 PHP-DI container configurator for Laminas, Mezzio, ZF, Expressive applications or any framework that needs a PSR-11 container
Stars: ✭ 19 (-85.93%)
Mutual labels:  laminas, mezzio
SlmMail
Send mail from Laminas or Mezzio using external mail services.
Stars: ✭ 107 (-20.74%)
Mutual labels:  laminas, mezzio
ApigilityConsumer
πŸƒ Zend Framework/Laminas and Expressive/Mezzio Apigility/Laminas API Tools Client Module to consume API Services
Stars: ✭ 15 (-88.89%)
Mutual labels:  laminas, mezzio
twbs-helper-module
Laminas (formerly Zend Framework) module for easy integration of Twitter Bootstrap
Stars: ✭ 18 (-86.67%)
Mutual labels:  laminas
zf3-circlical-user
Turnkey Authentication, Identity, and RBAC for Laminas and Zend Framework 3. Supports Doctrine and Middleware.
Stars: ✭ 35 (-74.07%)
Mutual labels:  laminas
psr-container-messenger
Message bus and queue for Mezzio with Symfony Messenger + Enqueue
Stars: ✭ 24 (-82.22%)
Mutual labels:  mezzio
PHP-Frameworks-Bench
Popular PHP Frameworks Benchmark.
Stars: ✭ 28 (-79.26%)
Mutual labels:  laminas
stefano-tree
Framework agnostic Nested Set (MPTT) implementation for PHP
Stars: ✭ 24 (-82.22%)
Mutual labels:  laminas
api
DotKernel's PSR-7 REST style API built around the Mezzio API skeleton.
Stars: ✭ 16 (-88.15%)
Mutual labels:  mezzio
mezzio-tooling
Migration and development tooling for Mezzio
Stars: ✭ 14 (-89.63%)
Mutual labels:  mezzio
zf-dependency-injection
Advanced dependency injection for laminas framework
Stars: ✭ 17 (-87.41%)
Mutual labels:  laminas
Jobber
Jobber is lightweight, simple and distributed task scheduler.
Stars: ✭ 25 (-81.48%)
Mutual labels:  job-worker
mezzio-cors
CORS component for Mezzio and other PSR-15 middleware runners.
Stars: ✭ 13 (-90.37%)
Mutual labels:  mezzio
petstore
A simple skeleton to build api's based on the chubbyphp-framework, mezzio (former zend-expressive) or slim.
Stars: ✭ 34 (-74.81%)
Mutual labels:  mezzio
SanSessionToolbar
⚑ Session Toolbar that can be applied into Zend/Laminas DeveloperTools
Stars: ✭ 39 (-71.11%)
Mutual labels:  laminas
zeebe-client-node-js
Node.js client library for Zeebe Microservices Orchestration Engine
Stars: ✭ 109 (-19.26%)
Mutual labels:  job-worker
enlite-monolog
Monolog integration to Laminas
Stars: ✭ 17 (-87.41%)
Mutual labels:  laminas
DoctrineMongoODMModule
Laminas Module for Doctrine MongoDB ODM
Stars: ✭ 83 (-38.52%)
Mutual labels:  laminas

SlmQueue

Latest Stable Version

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:

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:

  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.

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:

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

After installation of the package, you need to complete the following steps to use SlmQueue:

  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).

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.

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

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:

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('[email protected]', '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.

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

$ 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!

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

  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.

Who to thank?

Jurian Sluiman and MichaΓ«l Gallego did the initial work on creating this repo, and maintained it for a long time.

Currently it is maintained by:

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].