bupy7 / zf-queue
This package is abandoned and no longer maintained.
No replacement package was suggested.
A queue module for Laminas.
2.0.0
2020-11-28 15:43 UTC
Requires
- php: ^7.1
- container-interop/container-interop: ^1.2
- laminas/laminas-modulemanager: ^2.7
- laminas/laminas-servicemanager: ^3.1
- laminas/laminas-stdlib: ^3.1
Requires (Dev)
- friendsofphp/php-cs-fixer: ^2.4
- laminas/laminas-test: ^3.0
- php-coveralls/php-coveralls: ^2.2
- phpunit/phpunit: ^6.0
This package is auto-updated.
Last update: 2022-12-28 20:28:27 UTC
README
Abstract queue module for Laminas. Module contains only abstract layers to create their own integrations using this module.
Installation
The preferred way to install this extension is through composer.
Either run
$ php composer.phar require bupy7/zf-queue "*"
or add
"bupy7/zf-queue": "*"
to the require section of your composer.json file.
Integration
Ready integrations
Create their own integration
TODO
Usage
Create task
Let's create our first an example task for queue:
// YourModule/src/task/ExampleTask.php namespace YourModule\Task; use Bupy7\Queue\Task\TaskInterface; use Laminas\Stdlib\ParametersInterface; use Chat\Service\ChatService; class SendAccountTask implements TaskInterface { /** * @var ChatService */ protected $chatService; public function __construct(ChatService $chatService) { $this->chatService = $chatService; } /** * @param ParametersInterface $params * - message (string) * @return bool */ public function execute(ParametersInterface $params): bool { $this->chatService->send($params->get('message')); return true; } }
Run task
After you need to register task to queue manager:
// YouModule/config/queue.config.php namespace YourModule; return [ 'queue_manager' => [ 'factories' => [ Task\ExampleTask::class => \Laminas\ServiceManager\AbstractFactory\ReflectionBasedAbstractFactory::class, ], ], ];
Now, add queue.config.php
to your config list:
// YourModule/src/YourModule.php class Module { public function getConfig(): array { return array_merge( // another config files require __DIR__ . '/../config/queue.config.php' ); } }
Add the task to queue
$container->get('Bupy7\Queue\Service\QueueService')->add('YourModule\Task\ExampleTask');
Run queue
$container->get('Bupy7\Queue\Service\QueueService')->run();
License
zf-queue is released under the BSD 3-Clause License.