PHPackages                             communitales/command-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. [Utility &amp; Helpers](/categories/utility)
4. /
5. communitales/command-bus

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

communitales/command-bus
========================

Communitales Command Bus Component

2.2.0(1y ago)04.7k—0%MITPHPPHP &gt;=8.3

Since Nov 11Pushed 1y ago1 watchersCompare

[ Source](https://github.com/communitales/command-bus)[ Packagist](https://packagist.org/packages/communitales/command-bus)[ Docs](https://www.communitales.com)[ RSS](/packages/communitales-command-bus/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (10)Dependencies (11)Versions (11)Used By (0)

Communitales Command Bus Component
==================================

[](#communitales-command-bus-component)

Decouple applications with a synchronous command bus.

Setup
-----

[](#setup)

```
composer require communitales/command-bus

```

Setup for Symfony in `services.yaml`:

```
services:

    _instanceof:
        Communitales\Component\CommandBus\CommandBusAwareInterface:
            calls:
                - [setCommandBus, ['@Communitales\Component\CommandBus\CommandBus']]

        Communitales\Component\CommandBus\Handler\CommandHandlerInterface:
            tags: ['communitales.command_handler']

    Communitales\Component\CommandBus\CommandBus:
        arguments:
            - !tagged_iterator communitales.command_handler

```

Usage
-----

[](#usage)

Example of a command:

```

namespace App\Domain\Command\Customer;

use Communitales\Component\CommandBus\Command\CommandInterface;
use App\Entity\Customer;

readonly class CreateCustomerCommand implements CommandInterface
{
    public function __construct(public Customer $customer)
    {
    }
}

```

Example of a command handler:

```

namespace App\Domain\Handler\Customer;

use App\Domain\Command\Customer\CreateCustomerCommand;
use App\Domain\Command\Customer\DeleteCustomerCommand;
use App\Domain\Command\Customer\UpdateCustomerCommand;
use App\Repository\CustomerRepository;
use Communitales\Component\CommandBus\Command\CommandInterface;
use Communitales\Component\CommandBus\Handler\CommandHandlerInterface;
use Communitales\Component\CommandBus\Handler\CommandHandlerTrait;
use Communitales\Component\CommandBus\Handler\Result\CommandHandlerResultInterface;
use Communitales\Component\CommandBus\Handler\Result\SuccessResult;
use Communitales\Component\StatusBus\StatusMessage;
use Override;
use Symfony\Component\Translation\TranslatableMessage;

use function sprintf;

class CustomerCommandHandler implements CommandHandlerInterface
{
    use CommandHandlerTrait;

    public function __construct(private readonly CustomerRepository $customerRepository) {
    }

    #[Override]
    public function canHandle(CommandInterface $command): bool
    {
        return $command instanceof CreateCustomerCommand
            || $command instanceof UpdateCustomerCommand
            || $command instanceof DeleteCustomerCommand;
    }

    private function createCustomer(CreateCustomerCommand $command): CommandHandlerResultInterface
    {
        $customer = $command->customer;

        $this->customerRepository->save($customer);

        return new SuccessResult(
            StatusMessage::createSuccessMessage(
                new TranslatableMessage(
                    'domain_customer.result_created', ['name' => $customer->getName()]
                )
            )
        );
    }

    private function updateCustomer(UpdateCustomerCommand $command): CommandHandlerResultInterface
    {
        // ...
    }

    private function deleteCustomer(DeleteCustomerCommand $command): CommandHandlerResultInterface
    {
        // ...
    }
}

```

###  Health Score

38

—

LowBetter than 85% of packages

Maintenance32

Infrequent updates — may be unmaintained

Popularity21

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity75

Established project with proven stability

 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

Every ~147 days

Recently: every ~239 days

Total

10

Last Release

686d ago

Major Versions

1.2.0 → v2.0.02024-03-15

PHP version history (4 changes)v1.0.0PHP &gt;=7.4

v1.1.0PHP &gt;=8.0

1.2.0PHP &gt;=8.2

v2.0.0PHP &gt;=8.3

### Community

Maintainers

![](https://www.gravatar.com/avatar/c4e160cebfb3dbcb8bc49d1b408e61ddaa3e18535537307c3fe33f3a6212ae95?d=identicon)[communitales](/maintainers/communitales)

---

Top Contributors

[![sven-communitales](https://avatars.githubusercontent.com/u/13959824?v=4)](https://github.com/sven-communitales "sven-communitales (10 commits)")

---

Tags

phpcommand bus

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan, Psalm, Rector

Code StylePHP CS Fixer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/communitales-command-bus/health.svg)

```
[![Health](https://phpackages.com/badges/communitales-command-bus/health.svg)](https://phpackages.com/packages/communitales-command-bus)
```

###  Alternatives

[imanghafoori/laravel-anypass

A minimal yet powerful package to help you in development.

21421.6k](/packages/imanghafoori-laravel-anypass)

PHPackages © 2026

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