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

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

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

webware/command-bus

最新稳定版本:0.3.0

Composer 安装命令:

composer require webware/command-bus

包简介

CommandBus for Mezzio

README 文档

README

A Command Bus implementation for Mezzio applications, providing a clean way to handle commands through a middleware pipeline.

Table of Contents

Core Components

Interfaces

Container Factories

Middleware

Handlers

Exceptions

Quick Start

Installation

composer require php-cmd/cmd-bus

Basic Configuration

// config/config.php return [ Webware\CommandBus\ConfigProvider::class => [ 'command-map' => [ App\Command\CreateUserCommand::class => App\Handler\CreateUserHandler::class, ], 'middleware_pipeline' => [ ['middleware' => \Webware\CommandBus\Middleware\CommandHandlerMiddleware::class, 'priority' => 1], ], ], ];

Usage in Mezzio

// In a request handler or middleware class UserHandler { public function __construct( private \Webware\CommandBus\CmdBusInterface $commandBus ) {} public function handle(ServerRequestInterface $request): ResponseInterface { $data = $request->getParsedBody(); $command = new CreateUserCommand( email: $data['email'], username: $data['username'] ); $user = $this->commandBus->handle($command); return new JsonResponse(['user' => $user->toArray()]); } }

Architecture Overview

The cmd-bus library follows these key principles:

  1. Commands are data objects that implement CommandInterface
  2. Handlers process commands and implement CommandHandlerInterface
  3. Middleware can intercept and potentially modify command processing
  4. Pipeline manages middleware execution order
  5. Factory classes integrate with Laminas ServiceManager/ Psr\Container\ContainerInterface

Contributing

See the project repository for contribution guidelines and development setup instructions.

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: BSD-3-Clause
  • 更新时间: 2026-01-04