承接 ashleydawson/command-bus 相关项目开发

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

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

ashleydawson/command-bus

Composer 安装命令:

composer require ashleydawson/command-bus

包简介

Command bus and executable commands with a return/response

README 文档

README

Build Status

Super-simple command bus implementation that allows return types. Each command has a single, designated handler.

Note: Depending on your architecture - it might not be appropriate for commands to return a response. Typically, in CQS architecture, state change is observed/measured via events or queries.

Installation

Install the command bus library via Composer:

$ composer require ashleydawson/command-bus

Basic Usage

To use the command bus, start by adding a command:

<?php

namespace Acme\Command;

class MyCommand
{
    public $something;
}

Then, define a command handler for the command, command handlers must implement the magic __invoke() method, type-hinted with the command to be handled:

<?php

namespace Acme\Command;

class MyCommandHandler
{
    public function __invoke(MyCommand $command)
    {
        // Do something with the command here
        
        return 'Something useful';
    }
}

Then, put everything together (add command handler to command bus and execute command):

<?php

require __DIR__.'/vendor/autoload.php';

use AshleyDawson\CommandBus\CommandBus;
use Acme\Command\MyCommand;
use Acme\Command\MyCommandHandler;

// Instantiate a command bus
$commandBus = new CommandBus();

// Add a handler to the bus
$commandBus->addHandler(new MyCommandHandler());

// Execute a command, "Something useful" will be echoed
echo $commandBus->execute(new MyCommand());

Tests

To run the test suite, execute the following:

$ bin/phpunit

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2017-01-02

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固