PHPackages                             arkonsoft/ps-module-cqrs - 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. arkonsoft/ps-module-cqrs

ActiveLibrary

arkonsoft/ps-module-cqrs
========================

Custom CQRS for PrestaShop module

v2.0.2(3mo ago)052MITPHPPHP &gt;=8.1CI passing

Since Aug 21Pushed 3mo agoCompare

[ Source](https://github.com/Arkonsoft/PS-Module-CQRS)[ Packagist](https://packagist.org/packages/arkonsoft/ps-module-cqrs)[ RSS](/packages/arkonsoft-ps-module-cqrs/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (3)Dependencies (3)Versions (9)Used By (0)

PS Module CQRS
==============

[](#ps-module-cqrs)

A lightweight CQRS (Command Query Responsibility Segregation) implementation for PrestaShop modules. Uses PHP 8 attributes to bind commands and queries to their handlers — no registry or convention-based resolution.

Table of Contents
-----------------

[](#table-of-contents)

- [Description](#description)
- [Requirements](#requirements)
- [Installation](#installation)
- [Usage](#usage)
    - [Basic Setup](#basic-setup)
    - [The HandledBy Attribute](#the-handledby-attribute)
    - [Creating Commands and Handlers](#creating-commands-and-handlers)
    - [Creating Queries and Handlers](#creating-queries-and-handlers)
    - [Using the Buses](#using-the-buses)
- [Handler Resolution (callable)](#handler-resolution-callable)
- [Error Handling](#error-handling)
- [Migration from Convention-Based Binding](#migration-from-convention-based-binding)
- [License](#license)
- [Support](#support)

Description
-----------

[](#description)

This library provides a simple way to implement the CQRS pattern in PrestaShop modules. It includes `CommandBus` and `QueryBus` classes that resolve handlers at runtime by reading the `#[HandledBy(HandlerClass::class)]` attribute from the command or query class. There is no registry, no builder, and no naming convention — you pass a **callable** that creates handler instances (e.g. from your DI container or `new $class()`).

Requirements
------------

[](#requirements)

- PHP &gt;= 8.1
- PrestaShop &gt;= 8.0.0

The library does **not** require any specific DI container. You provide a callable that resolves handler class names to instances.

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

[](#installation)

```
composer require arkonsoft/ps-module-cqrs
```

Usage
-----

[](#usage)

### Basic Setup

[](#basic-setup)

In your module's main class, create the buses by passing a **callable** that receives the handler class name (string) and returns the handler instance:

```
