- What is rezzza/command-bus used for?
- It is a lightweight command bus for PHP and Laravel that maps command objects to dedicated handler classes. This helps move business logic out of controllers and into explicit command and handler classes. It also supports middleware, so you can add cross-cutting behavior around command handling.
- How do I install rezzza/command-bus in Laravel?
- Install it with Composer using composer require rezzza/command-bus. In a Laravel application, you typically register the package service provider if one is provided and configure the command-to-handler mappings in a service provider. Check the package README for the exact provider class and configuration steps for your version.
- How do I map a command to its handler?
- Mapping is done by associating each command class with its handler class, usually through configuration or a service provider registration. When the command bus dispatches a command, it resolves the matching handler and invokes it. The exact mapping syntax depends on the package version, so follow the README examples.
- Does rezzza/command-bus support middleware?
- Yes, the package supports middleware around command handling. Middleware lets you run logic before or after a command is handled, such as transactions, logging, authorization, or validation. You register middleware in the bus configuration and they execute in the order you define.
- Which Laravel versions are supported?
- The package is described as a lightweight command bus for PHP/Laravel, but the provided context does not list specific Laravel version constraints. Check the package composer.json and README for the supported PHP and Laravel versions before installing. That is especially important if you are upgrading an existing Laravel application.
- Can I use rezzza/command-bus outside Laravel?
- Yes, it is described as a lightweight command bus for PHP/Laravel, so the core bus is usable in plain PHP applications. Laravel integration adds convenience for service resolution and configuration, but the command and handler pattern does not require the framework. You would wire the bus and handler mappings manually in a non-Laravel app.
- How do I test commands and handlers with this package?
- You can unit test handlers directly by instantiating them with mocked dependencies and calling their handle method. For integration tests, dispatch commands through the command bus and assert the expected side effects or responses. Middleware can also be tested by registering test middleware and verifying it runs around the handler.
- Is rezzza/command-bus suitable for production?
- It is a lightweight library intended to organize business logic into command and handler classes, which can be used in production Laravel applications. Before deploying, verify the package's maintenance status, PHP/Laravel compatibility, and test coverage for your use case. Also review how you handle transactions and failures in middleware.
- What are alternatives to rezzza/command-bus?
- Alternatives include other PHP command bus packages such as Tactician, SimpleBus, and Laravel-focused bus implementations built around Laravel's container and pipeline. Some teams also use Laravel jobs or action classes instead of a dedicated command bus. The best choice depends on whether you need middleware, strict command-handler mapping, and framework independence.
- Is rezzza/command-bus actively maintained?
- The provided context does not include repository activity or release history, so maintenance status cannot be confirmed from this information alone. Check the package on Packagist and its repository for recent commits, releases, and open issues. If maintenance is stale, confirm compatibility with your Laravel version before adopting it.