The Laminas configuration provider that registers all cmd-bus components with the service container.
ConfigProvider is the central configuration class that integrates the cmd-bus library with Laminas ServiceManager. It defines service factories, aliases, command mappings, and middleware pipeline configuration following Laminas component standards.
final class ConfigProvider
{
public const COMMAND_MAP_KEY = 'command-map';
public const DEFAULT_PRIORITY = 1;
public const MIDDLEWARE_PIPELINE_KEY = 'middleware_pipeline';
public function __invoke(): array;
public function getDependencies(): array;
public function getCommandMap(): array;
public function getMiddleware(): array;
}COMMAND_MAP_KEY- Configuration key for command-to-handler mappingsDEFAULT_PRIORITY- Default priority for middleware (1)MIDDLEWARE_PIPELINE_KEY- Configuration key for middleware pipeline
Returns the complete configuration array for the cmd-bus module.
Returns:
- Array with
dependenciesand module-specific configuration
Returns service manager configuration including factories and aliases.
Returns the default command-to-handler mapping (empty by default).
Returns the default middleware pipeline configuration.
// config/config.php
use Laminas\ConfigAggregator\ConfigAggregator;
$aggregator = new ConfigAggregator([
// Other config providers...
Webware\CommandBus\ConfigProvider::class,
]);// config/autoload/cmd-bus.global.php
return [
Webware\CommandBus\CommandBusInterface::class => [
'command-map' => [
// User management commands
App\Command\User\CreateUserCommand::class => App\Handler\User\CreateUserHandler::class,
// Order management commands
App\Command\Order\PlaceOrderCommand::class => App\Handler\Order\PlaceOrderHandler::class,
// Notification commands
App\Command\Notification\SendEmailCommand::class => App\Handler\Notification\SendEmailHandler::class,
],
'middleware_pipeline' => [
[
'middleware' => Webware\CommandBus\Middleware\CommandHandlerMiddleware::class,
'priority' => 1
],
],
],
];The ConfigProvider automatically registers these services:
CommandBusInterface→CommandBusMiddlewarePipelineInterface→MiddlewarePipe
CommandBus→Container\CommandBusFactoryCommandHandlerFactory→Container\CommandHandlerFactoryFactoryMiddlewarePipe→Container\MiddlewarePipeFactoryCommandHandlerMiddleware→Container\CommandHandlerMiddlewareFactoryEmptyPipelineHandler→InvokableFactory
'command-map' => [
// Examples:
App\Command\CreateUserCommand::class => App\Handler\CreateUserHandler::class,
App\Query\GetUserQuery::class => App\Handler\GetUserHandler::class,
]'middleware_pipeline' => [
// Example:
[
'middleware' => App\Middleware\AuthMiddleware::class,
'priority' => 2 // Higher numbers execute first
],
]- CommandBus - Main service configured by this provider
- MiddlewarePipe - Pipeline service configured by this provider
- Container Factories - Service factories registered by this provider