PHP code example of black / cqrs-php

1. Go to this page and download the library: Download black/cqrs-php library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

black / cqrs-php example snippets




$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);



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);
}
json
{
    "lack/cqrs-php": "@stable"
    }
}
 php

// app/AppKernel.php

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