承接 psamatt/service-bus-lite-bundle 相关项目开发

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

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

psamatt/service-bus-lite-bundle

Composer 安装命令:

composer require psamatt/service-bus-lite-bundle

包简介

ServiceBus bundle implementation in Symfomy2

README 文档

README

Bundle that integrates Service Bus into Symfony2 through a bundle.

Installation using Composer

This bundle can be installed using composer by adding the following in the require section of your composer.json file:

    "require": {
        ...
        "psamatt/service-bus-lite-bundle": "*"
    },

Then, enable the bundle in the AppKernel:

<?php
// app/AppKernel.php

public function registerBundles()
{
    $bundles = array(
        // ...
        new Psamatt\ServiceBusLiteBundle\PsamattServiceBusLiteBundle(),
    );
}

How to use

Create Query or Command Handlers that implement ServiceBus\IQueryHandler or ServiceBus\ICommandHandler respectively such as:

use \ServiceBus\ICommand;

class FooCommandHandler implements \ServiceBus\ICommandHandler
{
    function handle(ICommand $command)
    {
        
    }
}

Then register the Handler as a service, tagged as a ServiceBus Handler in services.yml:

services:
    # Command Handler
    foo.command.handler:
        class: Acme\HelloBundle\CommandHandler\FooCommandHandler
        tags:
            -  { name: servicebus.command_handler }

    # Query Handler 
    foo.query.handler:
        class: Acme\HelloBundle\QueryHandler\FooQueryHandler
        tags:
            -  { name: servicebus.query_handler }

Tagging this service as a command or query handler will allow the service bus to register this class as an awaiting handler for an upcoming command.

Now all you have to do is initialise a FooCommand within your Controller and send to the ServiceBus

class FooController extends Controller
{
    
    public function indexAction()
    {
        // we send Commands
        $this->get('ServiceBus.Mediator')->send(new FooCommand('myEventName'));
        
        // we request Queries
        $response = $this->get('ServiceBus.Mediator')->request(new FooQuery('myEventName'));
    }

In the background, the ServiceBus will find the associated Handler where you would code the logic required for that specific action.

Further code example can be found in the example folder of the main repository

Note: It is important that your Command and your CommandHandler classes have Command and CommandHandler appended to the Class name for the ServiceBus to find the related CommandHandler for a raised Command.

统计信息

  • 总下载量: 4.43k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 5
  • 点击次数: 4
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2014-01-17

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固