dev-master
9999999-devLaravel ServiceProvider for the Tactician CommandBus library
The Requires
by Xander Smalbil
laravel commandbus tactician
Wallogit.com
2017 © Pedro Peláez
Laravel ServiceProvider for the Tactician CommandBus library
Laravel ServiceProvider for the Tactician library https://github.com/thephpleague/tactician/, (*2)
If you are looking for a Symfony2 Bundle or want to help: https://github.com/xtrasmal/TacticianBundle, (*3)
First add this provider to your composer dependencies:, (*4)
> composer require xtrasmal\tactician-provider, (*5)
Then register it in your config/app.php., (*6)
'providers' => [
'Xtrasmal\TacticianProvider\TacticianServiceProvider',
// ...
That's it!, (*7)
The most common use case with Tactician is passing a Command to the Command Bus and having it routed to the Command Bus., (*8)
Since handlers often have extra dependencies and are best lazily-loaded, you'll want to register them in the IoC container., (*9)
Let's say we have two classes, RegisterUserCommand and RegisterUserHandler. Add the following to config/tactician.php, (*10)
return [ 'buses' => [ 'default' => [ 'commandbus' => 'League\Tactician\CommandBus', 'middleware' => [ // ... ], 'commmands' => [ 'RegisterUser' => [ 'command' => 'Namespace\RegisterUserCommand', 'handler' => 'Namespace\RegisterUserHandler' ], 'RemoveUser' => [ 'command' => 'Namespace\RemoveUserCommand', 'handler' => 'Namespace\RemoveUserHandler' ], // ... ], ], ], ];
Laravel ServiceProvider for the Tactician CommandBus library
laravel commandbus tactician