PHPackages                             lezhnev74/prooph-direct-router - 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. lezhnev74/prooph-direct-router

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

lezhnev74/prooph-direct-router
==============================

v1.0.3(9y ago)0571MITPHPPHP ^7.1

Since Apr 15Pushed 8y ago1 watchersCompare

[ Source](https://github.com/lezhnev74/prooph-direct-router)[ Packagist](https://packagist.org/packages/lezhnev74/prooph-direct-router)[ RSS](/packages/lezhnev74-prooph-direct-router/feed)WikiDiscussions master Synced yesterday

READMEChangelogDependencies (4)Versions (5)Used By (0)

[![Latest Stable Version](https://camo.githubusercontent.com/93e712a65ae0fe9ebb07e37e58568bd06ba21a52dc64cd7b97338187ae04791c/68747470733a2f2f706f7365722e707567782e6f72672f6c657a686e657637342f70726f6f70682d6469726563742d726f757465722f762f737461626c65)](https://packagist.org/packages/lezhnev74/prooph-direct-router)[![Build Status](https://camo.githubusercontent.com/99f3edfa7aeba3ed95eff1a80fa8ca6d136d153953eaaa91199449daaa8ff5cd/68747470733a2f2f7472617669732d63692e6f72672f6c657a686e657637342f70726f6f70682d6469726563742d726f757465722e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/lezhnev74/prooph-direct-router)[![License](https://camo.githubusercontent.com/f1645f4a38e05d20483b943847c980d3b586eef475252dd00c697e269fd5f3d1/68747470733a2f2f706f7365722e707567782e6f72672f6c657a686e657637342f70726f6f70682d6469726563742d726f757465722f6c6963656e7365)](https://packagist.org/packages/lezhnev74/prooph-direct-router)[![Total Downloads](https://camo.githubusercontent.com/72f05296f4c9e7150fe8d5d545d3f72fc51acc096d3eb05ab99077791426d4e3/68747470733a2f2f706f7365722e707567782e6f72672f6c657a686e657637342f70726f6f70682d6469726563742d726f757465722f646f776e6c6f616473)](https://packagist.org/packages/lezhnev74/prooph-direct-router)

Implicit routing a command to it's handler
==========================================

[](#implicit-routing-a-command-to-its-handler)

A command is routed to the handler with the same name and "Handler" appended under the same namespace:

```
namespace Some\Space;

// your command
class Command {}

// your command handler
class CommandHandler {
    function __invoke(Command $cmd) {...}
}
```

Benefits
--------

[](#benefits)

By using conventions (implicit routing) you can easily add commands\\queries without constant updating configuration files. Just put both files in the same folder and follow the name convention:

- Handler class must be name exactly as a Command + `Handler` appended at the end
- Both command and a handler must reside under the same namespace

Just a handy tool :)

Installation
------------

[](#installation)

```
composer require lezhnev74/prooph-direct-router

```

Configuration
-------------

[](#configuration)

In case you use config files in your project, visit your `prooph.php` config file and update the "service\_bus.command\_bus.router.type" field. If you set up message bus manually, then scroll down to the "Usage" section.

```
//...
'service_bus' => [
    'command_bus' => [
        'router' => [
            'routes' => [
                // list of commands with corresponding command handler
            ],
            'type' => \DirectRouter\DirectRouter::class
        ],
    ],
//…
```

Usage
-----

[](#usage)

This package uses dependency-container to locate the handler for a given command, so you need to install some container package (which supports [ContainerInterface](http://www.php-fig.org/psr/psr-11/))

```
//
// Manual message bus setup
// 1. Prepare router
$router = new DirectRouter();
$router->attachToMessageBus($commandBus);
// 2. Add service locator (to instantiate the handler). $container is your implementation of PSR-11 ContainerInterface
$locator = new ServiceLocatorPlugin($container);
$locator->attachToMessageBus($bus);

//
// Dispatch command
//
$command = new \Some\Space\Command(...);
$commandBus->dispatch($command);
```

###  Health Score

28

—

LowBetter than 52% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity13

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity61

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 ~0 days

Total

4

Last Release

3363d ago

### Community

Maintainers

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

---

Top Contributors

[![lezhnev74](https://avatars.githubusercontent.com/u/10206110?v=4)](https://github.com/lezhnev74 "lezhnev74 (10 commits)")

---

Tags

proophrouter

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/lezhnev74-prooph-direct-router/health.svg)

```
[![Health](https://phpackages.com/badges/lezhnev74-prooph-direct-router/health.svg)](https://phpackages.com/packages/lezhnev74-prooph-direct-router)
```

###  Alternatives

[symfony/dependency-injection

Allows you to standardize and centralize the way objects are constructed in your application

4.2k447.1M9.1k](/packages/symfony-dependency-injection)[illuminate/contracts

The Illuminate Contracts package.

706127.7M12.7k](/packages/illuminate-contracts)[illuminate/container

The Illuminate Container package.

31180.7M2.3k](/packages/illuminate-container)[symfony/type-info

Extracts PHP types information.

20062.9M227](/packages/symfony-type-info)[ecotone/ecotone

Enterprise architecture layer for Laravel and Symfony — CQRS, Event Sourcing, Durable Workflows (Sagas, Orchestrators), Projections, and Outbox messaging via PHP attributes.

562565.8k42](/packages/ecotone-ecotone)[civicrm/civicrm-core

Open source constituent relationship management for non-profits, NGOs and advocacy organizations.

751284.3k37](/packages/civicrm-civicrm-core)

PHPackages © 2026

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