wallsfantasy/service-bus-laravel-package
Composer 安装命令:
composer require wallsfantasy/service-bus-laravel-package
包简介
A package for leveraging the Prooph Service Bus in a Laravel project
README 文档
README
This package supports the use of the prooph service buses inside of a Laravel application.
Features
- Support default buses that are bound to the classes
- Support unlimited named buses
- Add loggers to all buses
- Automatically resolve handlers
- Collect profiling data in debug mode
- Async switch
Installation
composer require camuthig/service-bus-laravel-package
Setup
Publish the Config
php artisan vendor:publish
Include the Provider
The package will automatically be discovered by Laravel when installed, no changes to include the service provider are needed.
Usage
Getting Default Buses
The default instance of each bus type can be retrieved in two ways:
<?php use \Camuthig\ServiceBus\Package\Test\Fixture\TestEvent; // Using the facade \Camuthig\ServiceBus\Package\Facade\EventBus::dispatch(new TestEvent()); // Getting the Prooph interface from the container app()->make(\Prooph\ServiceBus\EventBus::class)->dispatch(new TestEvent());
Each bus type (command, event and query) includes both a singleton interface as well as a facade.
ServiceBusManager
This package also supports having more than one of each bus type. To leverage a
non-default bus, you will want to use the ServiceBusManager. The manager gives
you access to all of the buses by name.
The service manager can be retrieved in three ways:
<?php // As a facade \Camuthig\ServiceBus\Package\Facade\ServiceBus::eventBus('other_bus'); // Getting the interface from the container $manager = app()->make(\Camuthig\ServiceBus\Package\Contracts\ServiceBusManager::class); $manager->eventBus('other_bus'); // Getting the `service_bus` from the container $manager = app()->make('service_bus'); $manager->eventBus('other_bus');
Configuration
The buses can be configured using the service_bus.php configuration file. Each
type of bus will have it's own list of of named buses with the following options:
- message_factory The service ID or class name of the message factory to use with the bus. The default is the prooph FQCNMessageFactory if this key is not provided.
- action_event_emitter The service ID or class name of the message factory to use with the bus. The default is the prooph ProophActionEventEmitter if this key is not provided.
- plugins A list of service IDs or class names of plugins to add to the the bus.
- router The configuration for the bus' router plugin. See details below
Router configuration
The router for each bus can be configured with:
- type The class name of a
MessageBusRouterPluginto use for this bus. It is expected that the constructor for the router should accept an array of route mappings. See the proophCommandRouter,EventRouter, andQueryRouterclasses for examples. This will default to the appropriate prooph router based on the type of the bus if not provided. - async_switch The service ID or class name of an
AsyncSwitchMessageRouterto add to the bus. If this value is not provided, no switch will be included on the bus. - routes A list of route mappings
- Command and query routing: Each entry in the list of routes is a "message name" to "message processor" (either a command handler or query finder).
- Event routing: Each entry in the list of routes is a "message name" to "list of listeners".
wallsfantasy/service-bus-laravel-package 适用场景与选型建议
wallsfantasy/service-bus-laravel-package 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 26 次下载、GitHub Stars 达 0, 最近一次更新时间为 2018 年 08 月 27 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 wallsfantasy/service-bus-laravel-package 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 wallsfantasy/service-bus-laravel-package 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 26
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 9
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: BSD-3-Clause
- 更新时间: 2018-08-27