PHPackages                             net-code/laravel-bus - 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. [API Development](/categories/api)
4. /
5. net-code/laravel-bus

ActiveLibrary[API Development](/categories/api)

net-code/laravel-bus
====================

Attribute-routed command &amp; query buses for Laravel with a configurable middleware pipeline.

v0.1.0(1mo ago)063MITPHPPHP ^8.5

Since Jul 10Pushed 1mo agoCompare

[ Source](https://github.com/Net-Tech-Marek-Rode-Sp-z-o-o/laravel-bus)[ Packagist](https://packagist.org/packages/net-code/laravel-bus)[ RSS](/packages/net-code-laravel-bus/feed)WikiDiscussions main Synced 1w ago

READMEChangelogDependencies (9)Versions (2)Used By (3)

net-code/laravel-bus
====================

[](#net-codelaravel-bus)

Attribute-routed **command** and **query** buses for Laravel, with a configurable middleware pipeline.

- A command/query is a plain object carrying a `#[HandledBy(Handler::class)]` attribute.
- The bus resolves the named handler from the container and invokes it (`__invoke`).
- Handlers run inside a **middleware pipeline** you configure per bus.

Extracted from the net-tech portfolio API so the CQRS kernel can be shared across projects.

Install
-------

[](#install)

```
composer require net-code/laravel-bus
```

The service provider is auto-discovered. It binds `CommandBus`, `QueryBus` and `TransactionManager` and wires the default middleware.

Usage
-----

[](#usage)

```
use NetCode\Bus\Command\Command;
use NetCode\Bus\Command\CommandHandler;
use NetCode\Bus\Command\HandledBy;

#[HandledBy(CreateUserHandler::class)]
final readonly class CreateUser implements Command
{
    public function __construct(public string $email) {}
}

final readonly class CreateUserHandler implements CommandHandler
{
    public function __invoke(CreateUser $command): string
    {
        // ...
        return $id;
    }
}
```

```
use NetCode\Bus\Command\CommandBus;

$id = app(CommandBus::class)->dispatch(new CreateUser('a@b.c'));
```

Queries are identical via `NetCode\Bus\Query\*` and `QueryBus::ask()`.

Middleware
----------

[](#middleware)

Ships with:

- **`TransactionMiddleware`** (command bus) — wraps each handler in a DB transaction.
- **`LoggingQueryMiddleware`** (query bus) — logs each dispatched query at debug level.

Both defaults are configurable. Publish the config to change them:

```
php artisan vendor:publish --tag=bus-config
```

```
// config/bus.php
return [
    'command' => ['middleware' => [
        NetCode\Bus\Laravel\TransactionMiddleware::class,
        App\Bus\AuthorizeMiddleware::class, // your own
    ]],
    'query' => ['middleware' => [
        NetCode\Bus\Laravel\LoggingQueryMiddleware::class,
    ]],
];
```

Middleware are resolved from the container (constructor injection works) and applied outermost-first. Custom middleware implement `CommandMiddleware` / `QueryMiddleware`.

Transactions
------------

[](#transactions)

`TransactionMiddleware` depends on `NetCode\Bus\TransactionManager`, bound by default to `LaravelTransactionManager` (uses the default DB connection). Rebind it to change the transaction boundary.

License
-------

[](#license)

MIT

###  Health Score

38

—

LowBetter than 83% of packages

Maintenance90

Actively maintained with recent releases

Popularity5

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity41

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

48d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/e1537b84454509a8f558fa6772528d6ef0942cd74e39c5224ae39e41ea9c841e?d=identicon)[mrode-net-tech](/maintainers/mrode-net-tech)

---

Top Contributors

[![mrode-net-tech](https://avatars.githubusercontent.com/u/158272218?v=4)](https://github.com/mrode-net-tech "mrode-net-tech (3 commits)")

---

Tags

laravelmessagingcommand busdddcqrsquery-bus

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StyleLaravel Pint

Type Coverage Yes

### Embed Badge

![Health badge](/badges/net-code-laravel-bus/health.svg)

```
[![Health](https://phpackages.com/badges/net-code-laravel-bus/health.svg)](https://phpackages.com/packages/net-code-laravel-bus)
```

###  Alternatives

[psalm/plugin-laravel

Psalm plugin for Laravel

3345.4M354](/packages/psalm-plugin-laravel)[laravel/ai

The official AI SDK for Laravel.

1.1k4.6M342](/packages/laravel-ai)[api-platform/laravel

API Platform support for Laravel

58190.1k21](/packages/api-platform-laravel)[simplestats-io/laravel-client

Server-side analytics for Laravel that follows the full funnel from visit to registration to payment, attributed to the channel that drove it. Revenue, MRR, churn and ad-spend profit (ROAS/CAC) per channel. GDPR compliant, ad-blocker proof.

5226.7k](/packages/simplestats-io-laravel-client)[aedart/athenaeum

Athenaeum is a mono repository; a collection of various PHP packages

265.2k](/packages/aedart-athenaeum)[illuminate/broadcasting

The Illuminate Broadcasting package.

7127.4M243](/packages/illuminate-broadcasting)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
