How phpmessagebus/messagebus works
Main Components
a) Three Core Message Bus Components:
• CommandBus
• QueryBus
• EventBus
b) Middleware Layers:
• Base Middleware
• Logging Middleware
• Transactional Middleware
• Cache Middleware (for QueryBus)
c) Supporting Components:
• Resolvers (Container integration)
• Translators
• Serializers
┌─ Application Layer ─────────────────────────────────────────┐
• ┌─ Command Bus ──┐ ┌─ Query Bus ───┐ ┌─ Event Bus ──┐ │
• Commands │ │ Queries │ │ Events │ │
• Handlers ─┼──>│ Handlers ─┼──>│ Handlers │ │
• ┘ └───────────────┘ └─────────────┘ │
• Middleware Layer ──────────────────────────────────────────┤
• ┌─────────────┐ ┌──────────────┐ ┌─────────────────┐ │
• Logging │ │ Transactional│ │ Cache (Query) │ │
• ┘ └──────────────┘ └─────────────────┘ │
• Infrastructure Layer ───────────────────────────────────────┤
• ┌─────────────┐ ┌──────────────┐ ┌─────────────────┐ │
• Resolvers │ │ Translators │ │ Serializers │ │
• ┘ └──────────────┘ └─────────────────┘ │
• ┘
Component Relationships
• Message flow through middleware
• Resolution of handlers through container
• Translation of messages to handlers
• Serialization points for caching/queuing
Specific Implementation Details
• Container support (PSR-11, Symfony, Interop)
• Supported serialization formats (Native, JSON, JsonObject)
• Middleware stack order
• Handler resolution strategies
Notes for Implementation
• Priority handling in Event Bus
• Transaction boundaries
• Cache integration points