nepster-web/php-simple-queue 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

nepster-web/php-simple-queue

最新稳定版本:1.0.0-Alpha-5

Composer 安装命令:

composer require nepster-web/php-simple-queue

包简介

Simple queues implementation in PHP through database.

README 文档

README

This package is under development. Api classes of this application can be changed.

PHP Simple Queue

Release Build Coverage Downloads License

Example of work

Introduction

PHP Simple Queue - a library for running tasks asynchronously via queues. It is production ready, battle-tested a simple messaging solution for PHP.

It supports queues based on DB.

Requirements

You'll need at least PHP 7.4 (it works best with PHP 8).

Installation

The preferred way to install this extension is through composer:

Either run

php composer.phar require --prefer-dist nepster-web/php-simple-queue

or add

"nepster-web/php-simple-queue": "*"

💻 Basic Usage

Create transport (see more information):

$transport = new \Simple\Queue\Transport\DoctrineDbalTransport($connection);

Send a new message to queue (producing)

$config = \Simple\Queue\Config::getDefault()
    ->registerProcessor('my_queue', static function(\Simple\Queue\Context $context): string {
        // Your message handling logic
        return \Simple\Queue\Consumer::STATUS_ACK;
    });
    
$producer = new \Simple\Queue\Producer($transport, $config);

$message = $producer->createMessage('my_queue', ['key' => 'value']);

$producer->send($message);

Job dispatching (producing)

$config = \Simple\Queue\Config::getDefault()
    ->registerJob(MyJob::class, new MyJob());

$producer = new \Simple\Queue\Producer($transport, $config);

$producer->dispatch(MyJob::class, ['key' => 'value']);

Processing messages from queue (consuming)

$producer = new \Simple\Queue\Producer($transport, $config);
$consumer = new \Simple\Queue\Consumer($transport, $producer, $config);

$consumer->consume();

For more details see the example code and read the guide.

Testing

To run the tests locally, in the root directory execute below

./vendor/bin/phpunit

or you can run tests in a docker container

cd .docker
make build
make start 
make composer cmd='test'

📖 Documentation

See the official guide.

📚 Resources

📰 Changelog

Detailed changes for each release are documented in the CHANGELOG.md.

🔒 License

See the MIT License file for license rights and limitations (MIT).

统计信息

  • 总下载量: 3.02k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 19
  • 点击次数: 1
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 19
  • Watchers: 1
  • Forks: 1
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2021-02-22