承接 cptburke/symfony-messenger-application-bundle 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

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

cptburke/symfony-messenger-application-bundle

Composer 安装命令:

composer require cptburke/symfony-messenger-application-bundle

包简介

bundle to use symfony-messenger-application (query, command, event, ...) in your symfony application

README 文档

README

bundle to use symfony-messenger-application (query, command, event, ...) in your symfony application

Installation

composer require cptburke/symfony-messenger-application-bundle

Configuration

This bundle tags classes that implement one of these interfaces via autoconfiguration:

  • CptBurke\Application\Query\QueryHandler gets tagged with messenger_application.query.handler
  • CptBurke\Application\Command\CommandHandler gets tagged with messenger_application.command.handler
  • CptBurke\Application\Domain\DomainEventSubscriber gets tagged with messenger_application.domain_event.subscriber
  • CptBurke\Application\Event\ApplicationEventSubscriber gets tagged with messenger_application.application_event.subscriber

It also pre-configures several buses:

  • messenger_application.query.bus Query bus with autoconfigured mapping for handlers that implement CptBurke\Application\Query\QueryHandler
  • messenger_application.domain_event.bus Domain event bus with autoconfigured mapping for subscribers that implement CptBurke\Application\Domain\DomainEventSubscriber
  • messenger_application.command.bus Command bus that takes an Symfony\Messenger\MessageBusInterface which can be configured through services.yaml, messenger.yaml
  • messenger_application.application_event.bus Application event bus that takes an Symfony\Messenger\MessageBusInterface which can be configured through services.yaml, messenger.yaml

To use async transport for command or application event buses, you can leverage the SendMessageMiddleware configured by the transport config

  • messenger_application.transport.senders takes a map of message classes to a list of transports

config/packages/messenger_application.yaml

The minimal configuration contains services for the command bus and the application event bus (if you want to use them in your application).

config/services.yaml

    #...
    
    command.handler_middleware:
        factory: [CptBurke\Application\SymfonyMessengerBundle\Factory\HandlerMiddlewareStackFactory, createCallables]
        arguments:
          - !tagged_iterator messenger_application.command.handler
    
    #...

config/packages/messenger.yaml

    buses:
    #...
      command.bus:
        default_middleware: false
        middleware:
          - doctrine_transaction
          - messenger_application.transport.senders
          - command.handler_middleware
messenger_application:

    # service id of the configured symfony message bus
    command_bus: 'command.bus'
    
    # service id of the configured symfony message bus
    application_event_bus: 'app.async_bus'

    query_bus:
        # middleware before query gets handled
        before_handle:
            - Acme\Middleware\SomeMiddleware
        # middleware after query was handled
        after_handle: []
            
    domain_event_bus:
        before_handle:
            - 'app.middleware.some_middleware'
        after_handle:
            - Acme\Middleware\LoggerMiddleware

    # SomeCommand would be sent to DoctrineTransport service
    transport:
        senders:
            Acme\Command\SomeCommand: ['DoctrineTransport']

Usage

Example

<?php


use CptBurke\Application\Query\QueryBus;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;


class SampleController extends AbstractController
{

    public function sampleAction(QueryBus $bus)
    {
        $data = $bus->ask(new GetDataQuery());
        // or
        $data = $this->get(QueryBus::class)->ask(new GetDataQuery());
        // or
        $data = $this->get('messenger_application.query.bus')->ask(new GetDataQuery());
        
        return $this->json($data);
    }

统计信息

  • 总下载量: 76
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 2
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

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

其他信息

  • 授权协议: mit
  • 更新时间: 2021-11-09

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固