league/tactician-container
PSR-11 container plugin for League Tactician that lazily loads command handlers from your DI container. Install via Composer and integrate with Tactician to resolve handlers on demand for cleaner wiring and faster bootstrap.
Illuminate/Container), eliminating the need for additional infrastructure. Aligns with Laravel’s service container philosophy.composer require league/tactician-container and bind handlers to the container (Laravel’s bind() or singleton() methods).Bus::dispatch() → Tactician command bus).app()->bind() with explicit interfaces and constructor injection.singleton()).get() with type hints).CommandTestCase)?Bus facade) or augmenting it?HandleJobsMiddleware)?Bus facade with Tactician’s CommandBus, configured via app/Providers/AppServiceProvider.$this->app->bind(\League\Tactician\CommandBus::class, function ($app) {
$container = new \League\Tactician\Container\ContainerPlugin();
$bus = new \League\Tactician\CommandBus(
$container,
new \League\Tactician\Middleware\MiddlewareStack()
);
return $bus;
});
$this->app->bind(\App\Commands\ProcessOrder::class, function ($app) {
return new ProcessOrderHandler($app->make(OrderRepository::class));
});
MiddlewareStack:
$middlewareStack = new \League\Tactician\Middleware\MiddlewareStack();
$middlewareStack->add(new \League\Tactician\Middleware\LoggingMiddleware());
Bus::dispatch().// Before
$handler = new ProcessOrderHandler($orderRepo);
$handler->handle(new ProcessOrder($orderId));
// After
Bus::dispatch(new ProcessOrder($orderId));
League\Tactician\CommandHandlerInterface.league/container). Use namespace isolation if needed.AppServiceProvider.app()->make() or constructor injection).Bus::dispatch() in unit/integration tests.singleton()).app()->bound() to verify handler bindings.CommandBusException for runtime errors (e.g., unhandled commands).CommandTestCase for automated testing.| Failure Scenario | Impact | Mitigation | |-------------------------------------|--------------------------------
How can I help you explore Laravel packages today?