承接 antidot-fw/tactician 相关项目开发

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

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

antidot-fw/tactician

Composer 安装命令:

composer require antidot-fw/tactician

包简介

Tactician Command bus adapter for Antidot Framework.

README 文档

README

Latest Version on Packagist Software License Build Status Coverage Status Quality Score Total Downloads

Getting started

Installation

composer require antidot-fw/tactician

Config

Create command-bus.global.php file inner config autoload directory.

<?php
// command-bus.global.php

return [
    'dependencies' => [
        'invokables' => [
            \App\Handler\PingHandler::class => \App\Handler\PingHandler::class,
        ]
    ],
    'command-bus' => [
        'handler-map' => [
            \App\Command\PingCommand::class => \App\Handler\PingHandler::class
        ],
    ],
];

Example command and handler.

<?php

namespace App\Command;

class PingCommand
{

}
<?php

namespace App\Handler;

use App\Command\PingCommand;

class PingHandler
{
    public function __invoke(PingCommand $command)
    {
        return time();
    }
}

You can use InFw\TacticianAdapter\Action\AbstractAction as base action.

<?php

namespace App\Action;

use App\Command\PingCommand;
use Laminas\Diactoros\Response\JsonResponse;
use Psr\Http\Message\ResponseInterface;
use Psr\Http\Server\RequestHandlerInterface;
use Psr\Http\Message\ServerRequestInterface;

class PingAction implements RequestHandlerInterface
{
    public function handle(ServerRequestInterface $request): ResponseInterface
    {
        return new JsonResponse(['ack' => $this->bus->handle(new PingCommand())]);
    }
}

Modify Command Bus

You can modify the entire command bus to meet the needs of your project.

This is default config.

<?php
// command-bus.global.php

return [
    ...,
    'command_bus' => [
        'locator' => \League\Tactician\Handler\Locator\HandlerLocator::class,
        'inflector' => \League\Tactician\Handler\MethodNameInflector\MethodNameInflector::class,
        'extractor' => \League\Tactician\Handler\CommandNameExtractor\CommandNameExtractor::class,
        'middleware' => [
            \League\Tactician\Plugins\LockingMiddleware::class,
            \League\Tactician\Logger\LoggerMiddleware::class,
            \League\Tactician\CommandEvents\EventMiddleware::class,

        ],
    ],
];

Query Bus

You can use a query bus too, the difference with the command bus is that the query bus will always return an object.

<?php
// command-bus.global.php

return [
    ...,
    'query_bus' => [
        'locator' => 'query_bus.handler_locator',
        'inflector' => \League\Tactician\Handler\MethodNameInflector\MethodNameInflector::class,
        'extractor' => \League\Tactician\Handler\CommandNameExtractor\CommandNameExtractor::class,
        'middleware' => [

        ],
    ],
];

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: BSD-2-Clause
  • 更新时间: 2020-09-06

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固