PHPackages                             smoothcodes/smooth-query-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. smoothcodes/smooth-query-bus

ActiveLibrary

smoothcodes/smooth-query-bus
============================

02PHPCI failing

Since Apr 29Pushed 6y ago1 watchersCompare

[ Source](https://github.com/smoothcodes/SmoothQueryBus)[ Packagist](https://packagist.org/packages/smoothcodes/smooth-query-bus)[ RSS](/packages/smoothcodes-smooth-query-bus/feed)WikiDiscussions master Synced 5d ago

READMEChangelogDependenciesVersions (1)Used By (0)

SmoothQueryBus
==============

[](#smoothquerybus)

This simple package will help you to implement Query part of CQRS in your project. Easy to integrate with Laravel, Symfony or raw PHP project.

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

[](#installation)

```
$ composer require smoothcodes/smooth-query-bus
```

Usage
-----

[](#usage)

This package is using Psr\\ContainerInterface to resolve dependencies injected to Query Handlers. Symfony and Laravel Dependency Container is implementing ContainerInterface so it's really easy to implement SmoothQueryBus in your Symfony/Laravel Project.

By default this package provides HandlerResolver called ` SmoothCodes\SmoothQueryBus\SmoothHandlerResolver` and it requires project structure for your queries and handlers like this:

```
app
│   ...
│
└───Query
│   │   GetUserByIdQuery.php
│   │   ...
│
└───Handler
    │   GetUserByIdQueryHandler.php
    |   ...

```

Each `Query` should implement `SmoothCodes\SmoothQueryBus\QueryInterface` and each `Handler` should implement `SmoothCodes\SmoothQueryBus\QueryHandlerInterface`.

Now you're ready to dispatch your queries like that:

In handlers \_\_invoke method is called as action. So Handler should look like this:

```
class GetUserByIdQueryHandler implements HandlerInterface {
    protected $userRepository;

    public function __construct(UserRepositoryInterface $userRepository) {
        $this->userRepository = $userRepository;
    }

    public function __invoke(GetUserByIdQuery $query) {
        return $this->userRepository->find($query->id);
}
```

```
$queryBus = new SmoothQueryBus(
    new SmoothHandlerResolver($container)
);

$result = $queryBus->query(new GetUserByIdQuery($id));
```

If you want you can implement your own Query Handler Resolving Strategy by providing class implementing `SmoothCodes\SmoothQueryBus\HandlerResolvingStrategy` to `SmoothHandlerResolver` instance eg. like that:

```
        $namingResolver = new class($queryHandler) implements HandlerResolvingStrategy {
            private $queryHandler;

            public function __construct(QueryHandlerInterface $handler)
            {
                $this->queryHandler = $handler;
            }

            public function getHandlerClassName(QueryInterface $query)
            {
                return get_class($this->queryHandler);
            }
        };

        $queryBus = new SmoothQueryBus(
            new SmoothHandlerResolver($container, $namingResolver)
        );
```

instead default handler resolving strategy will be used.

That's very simple package which is fully customizable. Report any issues, give feedbacks or do some feature requests.

###  Health Score

17

—

LowBetter than 6% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity2

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity34

Early-stage or recently created project

 Bus Factor1

Top contributor holds 55.6% 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.

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/64445013?v=4)[smoothcodes](/maintainers/smoothcodes)[@smoothcodes](https://github.com/smoothcodes)

---

Top Contributors

[![rusinowiczjakub](https://avatars.githubusercontent.com/u/121547469?v=4)](https://github.com/rusinowiczjakub "rusinowiczjakub (5 commits)")[![smoothcodes](https://avatars.githubusercontent.com/u/64445013?v=4)](https://github.com/smoothcodes "smoothcodes (4 commits)")

### Embed Badge

![Health badge](/badges/smoothcodes-smooth-query-bus/health.svg)

```
[![Health](https://phpackages.com/badges/smoothcodes-smooth-query-bus/health.svg)](https://phpackages.com/packages/smoothcodes-smooth-query-bus)
```

PHPackages © 2026

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