jildertmiedema / laravel-tactician
Tactician for laravel 8+
Installs: 4 848
Dependents: 0
Suggesters: 0
Security: 0
Stars: 8
Watchers: 1
Forks: 5
Open Issues: 1
Requires
- php: >=8.1.0
- illuminate/support: ^10.0
- league/tactician: ^1.0
Requires (Dev)
- laravel/framework: ^10.0
- phpunit/phpunit: ^10.0
README
Tactician command bus for laravel 5+
Install
composer require jildertmiedema/laravel-tactician
Add JildertMiedema\LaravelTactician\TacticianServiceProvider
to your app.php
Run this in the command line:
php artisan vendor:publish
Edit config/tactician.php
and set your namespaces
Usage
In your controllers or console commands you can use the trait JildertMiedema\LaravelTactician\DispatchesCommands
.
use YourApp\Commmands\DoSomethingCommand; use Illuminate\Routing\Controller as BaseController; use JildertMiedema\LaravelTactician\DispatchesCommands; class Controller extends BaseController { use DispatchesCommands; public function store(Request $request) { $command = new DoSomethingCommand($request->get('id'), $request->get('value')); $this->dispatch($command); return redirect('/'); } }
Extending
Middleware
In your own ServiceProvider:
$this->app['tactician.middleware']->prepend('your.middleware'); $this->app->bind('your.middleware', function () { return new MiddleWare });
Locator
The default locator is set in the container by tactician.handler.locator
, of course you can change it.
In your own ServiceProvider:
$this->bind('tactician.handler.locator', function () { return new YourLocator(); });