Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Cqrs Php Laravel Package

black/cqrs-php

Minimal CQRS command bus for PHP/DDD without event sourcing. Define Command and CommandHandler, register handlers to commands, then dispatch via a single Bus. Includes optional Symfony bundle integration with service tags for handler registration.

View on GitHub
Deep Wiki
Context7

CQRS PHP

CQRS in PHP is a simple project (a folder structure) for your project build with Domain Driven Design.

Latest Stable Version Total Downloads

Installation

The recomanded way to install CQRS in PHP is through Composer:

{
    "require": {
        "black/cqrs-php": "@stable"
    }
}

Protip: You should browse the black/cqrs-php page to choose a stable version to use, avoid the @stable meta constraint.

Why?

I want to use a very basic library for CQRS without Event Sourcing. There is one Bus, register your handler with the related command and go for it!

Usage

1 - Create a Command implementing Black\DDD\CQRSinPHP\Infrastructure\CQRS\Command
2 - Create an Handler implementing Black\DDD\CQRSinPHP\Infrastructure\CQRS\CommandHandler
3 - Register the Handler/Command to the Bus

<?php

$bus = new Black\DDD\CQRSinPHP\Infrastructure\CQRS\Bus;
$handler = new My\Handler();

$bus->register('My\Command', $handler);

// Do stuff
$command = new My\Command($foo, $bar);
$bus->handle($command);

SymfonyBundle

Register the bundle:

<?php
// app/AppKernel.php

public function registerBundles()
{
    $bundles = array(
        // ...
        new Black\Bundle\CQRSBundle\BlackCQRSBundle(),
    );
}

Declare your handler as a service and add this tag:

services:
    my.handler:
        class: 'My\Handler'
        tags:
            - { name: black_cqrs.handler, command: "My\Command" }

And use it:

<?php

public function __construct(Black\DDD\CQRSinPHP\Infrastructure\CQRS\Bus $bus)
{
    $this->bus = $bus;
}

public function myFunction($foo, $bar)
{
    $command = new My\Command($foo, $bar);
    $this->bus->handle($command);
}

Contributing

This project is a work in progress so don't hesitate to see CONTRIBUTING file and submit your PR.

Credits

The code is heavily inspired by Benjamin Eberlei blog posts who did a very great job on many projects (including Doctrine and litecqrs-php.

This README is heavily inspired by Hateoas library by the great @willdurand. This guy needs your PR for the sake of the REST in PHP.

Alexandre "pocky" Balmes alexandre@lablackroom.com. Send me Flattrs if you love my work, buy me gift or hire me!

License

CQRS in PHP is released under the MIT License. See the bundled LICENSE file for details.

Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
craftcms/url-validator
directorytree/privacy-filter-classifier
directorytree/privacy-filter
datacore/hub-sdk
develia/commons
cuci/prototurk-sdk
cuci/prototurk-sdk-symfony
develia/geo-bundle
dreamzy/livewire-charts
touchestate-sdk/php-sdk
22h/doctrine-garbage-collection-bundle
agtp/agtp-php
agtp/mod-php
splash/sonata-admin
splash/metadata
splash/openapi
splash/scopes
splash/toolkit
testo/output-teamcity
testo/bridge-symfony