ddd-module/broadway
Broadway provides infrastructure and testing helpers for building CQRS and event-sourced PHP applications. It offers loosely coupled components for command handling, event storage, and projection workflows, designed to stay out of your way and be used together or separately.
CommandLogger).DBALEventStore for a custom solution) if Broadway’s abstractions are too opinionated.DBALEventStore for MongoDB later).DBALEventStore may not match the throughput of specialized solutions like EventStoreDB or Apache Kafka.*"Broadway lets us build scalable, audit-proof systems without reinventing CQRS/Event Sourcing from scratch. Think of it as Lego blocks for:
- Real-time data pipelines (e.g., sync inventory across warehouses via events).
- Unchangeable audit logs (critical for compliance in finance/healthcare).
- Decoupled microservices (write once, query many ways—e.g., APIs, dashboards, or analytics).
Why now?
- Reduces tech debt by avoiding custom event stores/command buses.
- Enables faster feature delivery for complex workflows (e.g., order processing).
- Future-proofs the architecture for growth (e.g., add Elasticsearch projections later).
Risk: Steeper learning curve for the team, but we can start with a pilot project (e.g., a single bounded context like ‘Payments’)."*
*"Broadway gives us batteries-included CQRS/ES for PHP/Laravel with:
- Modular components: Use just the event store, or the full stack (commands → events → projections).
- Testing superpowers: Built-in helpers for scenario testing (e.g., ‘Given X command, then Y events are emitted’).
- Flexible storage: Swap
DBALEventStorefor MongoDB/Elasticsearch later.- Audit trails: Log command failures automatically (no extra boilerplate).
How we’d use it:
- Start small: Replace a single Eloquent model with an event-sourced aggregate (e.g.,
UserProfile).- Add projections: Sync data to a read model (e.g., Elasticsearch for search).
- Scale: Extend with sagas or custom event handlers.
Alternatives considered:
- Roll our own: Too much reinvention (e.g., handling snapshots, playhead management).
- EventStoreDB: Overkill for PHP; Broadway is lighter and Laravel-friendly.
Next steps:
- Spike a proof-of-concept (e.g., port a simple feature like ‘User Signup’).
- Compare performance vs. Eloquent for our workload.
- Train the team on DDD/CQRS basics (resources: Broadway docs, EventSourcing.io)."*
*"Broadway helps us deliver complex features faster by:
- Decoupling reads/writes: Add a new dashboard (read model) without touching the core logic.
- Enabling real-time updates: Push events to services like Twilio (SMS) or Stripe (webhooks) automatically.
- Simplifying rollbacks: Since all state changes are events, we can rewind a user’s account to a previous state if needed.
Example: For a ‘Subscription Management’ feature, we’d:
- Define commands like
UpgradePlanCommand.- Let the system emit events like
PlanUpgradedEvent.- Project these events to a read-optimized table for the UI.
- Use sagas to handle cross-service workflows (e.g., cancel old plan → create new one).
Trade-offs:
- Upfront cost: 2–4 weeks to onboard the team and build the first aggregate.
- Long-term gain: Easier to add features (e.g., ‘undo’ buttons, analytics) later.
Ask the team:
- Which bounded context (e.g., ‘Payments’, ‘Inventory’) would benefit most from this?
- Can we A/B test Broadway vs. traditional Eloquent for a specific feature?"*
How can I help you explore Laravel packages today?