定制 pechenin/broker-action 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

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

pechenin/broker-action

Composer 安装命令:

composer require pechenin/broker-action

包简介

README 文档

README

Installation

Add bundle to config/bundles.php

BrokerAction\BrokerActionBundle::class => ['all' => true]

Create broker_action.yaml in config/packages folder

Example of broker_action.yaml:

broker_action:
  mapping:
      - { path: 'some.path', action: 'App\Actions\SomeAction' }
      - { path: 'some.path1', action: 'App\Actions\SomeAnotherAction' }

Action creation

Create class that implements BrokerAction\Framework\ActionInterface.

Example:

use BrokerAction\DTO\ActionResponse;
use BrokerAction\DTO\Error;
use BrokerAction\Framework\ActionInterface;

class SomeAction implements ActionInterface
{
    public function run($data): ActionResponse
    {
        $response = new ActionResponse();
        try {
            echo $data;
            $response->setData($data);
        } catch (\Exception $exception) {
            $response->setError(new Error($exception->getMessage()));
        }

        return $response;
    }
}

Find route and fire action

To fire action you should create TransactionMessageDTO object and pass it to route method of BrokerAction\Framework\Router.

Example:

use BrokerAction\Framework\Router;
use BrokerAction\DTO\TransactionMessage\TransactionMessageDTO;

class FooClass {
    
    private $router;
    
    public function (Router $router) {
        $this->router = $router;
    }
    
    public function bar() {
        $json = '{
                     "path": "some.path",
                     "payload": {
                         "acc_id": 1
                     }
                 }';
        $message = TransactionMessageDTO::fromJson($json);
        $reponse =$this->router->route($message);
    }
}

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: Unknown
  • 更新时间: 2019-09-16

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固