tourze/symfony-async-message-bundle

Symfony异步消息模块

0.0.3 2025-03-25 13:18 UTC

This package is auto-updated.

Last update: 2025-03-25 15:43:00 UTC


README

English | 中文

English

A Symfony bundle that provides asynchronous command execution capabilities using Symfony Messenger.

Features

  • Asynchronous command execution
  • Built-in error handling and logging
  • Support for command options and arguments
  • Integration with Symfony Messenger

Requirements

  • PHP 8.1 or higher
  • Symfony 6.4 or higher
  • Symfony Messenger component

Installation

composer require tourze/symfony-async-message-bundle

Configuration

Enable the bundle in your config/bundles.php:

return [
    // ...
    Tourze\Symfony\AsyncMessage\AsyncMessageBundle::class => ['all' => true],
];

Usage

  1. Create a message:
use Tourze\Symfony\AsyncMessage\Message\RunCommandMessage;

$message = new RunCommandMessage();
$message->setCommand('your:command');
$message->setOptions([
    '--option1' => 'value1',
    '--option2' => 'value2'
]);
  1. Dispatch the message:
$this->messageBus->dispatch($message, [
    new AsyncStamp()
]);

License

This bundle is licensed under the MIT License.

中文

一个使用 Symfony Messenger 提供异步命令执行功能的 Symfony Bundle。

特性

  • 异步命令执行
  • 内置错误处理和日志记录
  • 支持命令选项和参数
  • 与 Symfony Messenger 集成

要求

  • PHP 8.1 或更高版本
  • Symfony 6.4 或更高版本
  • Symfony Messenger 组件

安装

composer require tourze/symfony-async-message-bundle

配置

config/bundles.php 中启用 bundle:

return [
    // ...
    Tourze\Symfony\AsyncMessage\AsyncMessageBundle::class => ['all' => true],
];

使用方法

  1. 创建消息:
use Tourze\Symfony\AsyncMessage\Message\RunCommandMessage;

$message = new RunCommandMessage();
$message->setCommand('your:command');
$message->setOptions([
    '--option1' => 'value1',
    '--option2' => 'value2'
]);
  1. 发送消息:
$this->messageBus->dispatch($message, [
    new AsyncStamp()
]);

许可证

本 Bundle 基于 MIT 许可证。