league/tactician
Tactician is a small, pluggable PHP command bus. Route commands to handlers and extend behavior via middleware and plugins (logging, containers, Doctrine transactions, queuing, events, locking). Install with Composer and integrate with your framework of choice.
Start by installing the core package: composer require league/tactician. Define simple, plain PHP objects as commands (no interfaces needed since v0.4.0). Create handler classes with a public handle() method (or custom-named methods using inflectors). Set up a minimal command bus using League\Tactician\Core\CommandBus and the included CommandHandlerMiddleware, passing in a ClassNameExtractor and a HandlerLocator (e.g., CallableLocator for basic setups or ContainerLocator via league/tactician-container for DI integration). The README’s quick example shows this pattern clearly—start there for your first working bus.
MiddlewarePluginManager or manual stacking.league/tactician-container to lazy-load handlers—especially critical in production for performance.HandleClassNameWithoutSuffix to decouple handler method names from command class names (e.g., RentMovieCommand → handleRentMovie() instead of handle()), useful when renaming or aligning with domain semantics.tactician-doctrine for per-command DB transactions, tactician-logger for structured logging, tactician-bernard for async jobs.ClassNameExtractor is mandatory: For CommandHandlerMiddleware, forgetting to pass it (or misconfiguring the locator signature) leads to runtime errors—double-check constructor parameters.handle() method works, but inflectors like HandleClassNameWithoutSuffix require strict naming conventions; mismatched methods cause “no handler found” exceptions. Use handleXXX pattern consistently.LockingMiddleware could cause permanent locks—ensure you’re on v1.2.0+ and wrap bus execution in try/catch (Throwable).How can I help you explore Laravel packages today?