Download the PHP package victormln/laravel-tactician without Composer
On this page you can find all versions of the php package victormln/laravel-tactician. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download victormln/laravel-tactician
More information about victormln/laravel-tactician
Files in victormln/laravel-tactician
Package laravel-tactician
Short Description Laravel implementation of the Tactician Command Bus
License MIT
Informations about the package laravel-tactician
Laravel Tactician
Laravel Tactician in an implementation of the Command Bus Tactician by Ross Tuck and based on: joselfonseca/laravel-tactician
Installation
Simply do a composer require:
Or add this line to your composer.json file
Other
Once the dependencies have been downloaded, add the service provider to your config/app.php file
You are done with the installation!
Usage
To use the command bus you can resolve the bus from the laravel container like so
Or you can inject it into a class constructor
After inject the commandBus, you can dispatch the command as simple as this:
NOTE: This package is build to automatically grab the CommandHandler from the same path as the Command, so you don't have to do anything to bind the two files. But if you want, you can bind the command handler manually calling the addHandler method
For more information about the usage of the tactician command bus please visit http://tactician.thephpleague.com/
Example
Check out this example of the package implemented in a simple create order command https://gist.github.com/victormln/f06a86f7204b251d6d6c876d5e516a67
Bindings
You can configure the bindings for the locator, inflector, extractor and default bus publishing the config file like so
Then you can modify each class name and they will be resolved from the laravel container
Generators
You can generate Commands and Handlers automatically using artisan
This will create FooCommand and FooCommandHandler and place them in the app/CommandBus/Commands and app/CommandBus/Handlers respectively
To run both at once
Middleware included
Laravel tactician includes some useful middleware you can use in your commands
- Database Transactions: This Middleware will run the command inside a database transaction, if any exception is thrown the transaction won't be committed and the database will stay intact, you can find this middleware in
Victormln\LaravelTactician\Middleware\DatabaseTransactions
.
Change log
Please see the releases page https://github.com/victormln/laravel-tactician/releases
Tests
To run the test in this package, navigate to the root folder of the project and run
Then
Contributing
Please see CONTRIBUTING for details.
Security
If you discover any security related issues, please email jose at ditecnologia dot com instead of using the issue tracker.
Credits
- Based on Jose Luis Fonseca - LaravelTactician
- All Contributors
License
The MIT License (MIT). Please see License File for more information.