1. Go to this page and download the library: Download tactics/command-bus-bundle 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/ */
tactics / command-bus-bundle example snippets
use Pringles\DomainBundle\CommandBus\Command;
class RegisterUser implements Command
{
public $firstname;
public $lastname;
}
use Pringles\DomainBundle\CommandBus\CommandHandler;
class RegisterUserHandler implements CommandHandler
{
private $personRepository;
public function __construct(PersonRepository $personRepository)
{
$this->personRepository = $personRepository;
}
public function handle(RegisterUser $registerUser)
{
$person = Person::register($registerUser->firstname, $registerUser->lastname);
}
}
use Pringles\DomainBundle\CommandBus\SimpleCommandBus;
function someController()
{
$bus = new SimpleCommandBus(new ShortNameStrategy());
$bus->registerHandler(new RegisterUserHandler($personRepository));
$cmd = new RegisterUser;
$cmd->firstname = 'Aaron';
$cmd->lastname = 'Muylaert';
$bus->handle($cmd);
}
$cmd = new Test;
$cmd->value = 'Foo';
$this->get('command_bus')->handle($cmd);
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.