PHPackages                             awd-studio/service-buses - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. awd-studio/service-buses

ActiveLibrary

awd-studio/service-buses
========================

An implementation of such kind of patterns as: Command Bus, Query Bus and Event Bus; in a single package; driven by a Dependency Injection Container

v4.0.3(2y ago)1526MITPHPPHP ^8.2

Since Jun 26Pushed 2y agoCompare

[ Source](https://github.com/awd-studio/service-buses)[ Packagist](https://packagist.org/packages/awd-studio/service-buses)[ Docs](https://github.com/awd-studio/service-buses)[ RSS](/packages/awd-studio-service-buses/feed)WikiDiscussions master Synced today

READMEChangelog (8)Dependencies (11)Versions (23)Used By (0)

Service buses in PHP
====================

[](#service-buses-in-php)

A simple library, to implement `CQRS`-ish pattern on PHP projects.
------------------------------------------------------------------

[](#a-simple-library-to-implement-cqrs-ish-pattern-on-php-projects)

[![Build status](https://github.com/awd-studio/service-buses/actions/workflows/tests.yml/badge.svg)](https://github.com/awd-studio/service-buses/actions/workflows/tests.yml/badge.svg)[![Coverage Status](https://camo.githubusercontent.com/51edac1a956b132320e1724f2aedbf17ffa9da50a4a707f4b36d150be173547c/68747470733a2f2f636f766572616c6c732e696f2f7265706f732f6769746875622f6177642d73747564696f2f736572766963652d62757365732f62616467652e7376673f6272616e63683d6d6173746572)](https://coveralls.io/github/awd-studio/service-buses?branch=master)

#### Features:

[](#features)

- Neither messages nor handlers don't need to extend or implement any additional abstraction.
- A handler can be any of `callable` items.
- Handlers can subscribe on any of parents or implementations of an event.
- Contains a decorator to register handles as services handled via `PSR-11`'s container.
- Contains a decorator to auto-subscribe handlers by a typehint on a message that it handles.
- Provides ready to go bus patterns such a `Command Bus`, a `Query Bus` and an `Event Bus` implementations.

#### Contents:

[](#contents)

- [Get started](#get-started)
- [Handling messages](#handling-messages)
- [Predefined buses](#predefined-buses)
    - [Command Bus](#command-bus)
    - [Query Bus](#query-bus)
    - [Event Bus](#event-bus)
- [Subscribe on parents](#subscribe-on-parents)
- [Services as handlers](#services-as-handlers)
    - [Auto-register services](#auto-register-services)
    - [Using your own handling methods](#using-your-own-handling-methods)
- [Define custom bus](#define-custom-bus)
- [Testing](#testing)

---

Get started:
------------

[](#get-started)

### Requirenments:

[](#requirenments)

- PHP 8.2+
- [PSR-11](https://github.com/php-fig/container) - compatible container (*optional*)

### Install:

[](#install)

```
composer require awd-studio/service-buses
```

Handling messages:
------------------

[](#handling-messages)

A message, is nothing, but a simple PHP-object.

It can contain any data you need, but usually, it's better to provide some immutable messages, that can be serialized.

```
