Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Event Sourcing Bundle Laravel Package

dddominio/event-sourcing-bundle

View on GitHub
Deep Wiki
Context7

Technical Evaluation

Architecture Fit

  • Event Sourcing Alignment: The package aligns well with Domain-Driven Design (DDD) and Event Sourcing (ES) patterns, making it suitable for projects requiring auditability, replayability, or CQRS architectures.
  • Symfony Integration: Designed as a Symfony bundle, it leverages Symfony’s dependency injection, configuration, and event systems, reducing friction in adoption for existing Symfony applications.
  • Domain Model Flexibility: The underlying DDDominio Event Sourcing library appears to support aggregate roots, domain events, and event stores, which are core to ES implementations.
  • Potential Gaps:
    • No clear support for event projections (read models) or event sourcing snapshots (critical for performance at scale).
    • Limited documentation and community adoption (0 stars, 0 dependents) may indicate untested edge cases.

Integration Feasibility

  • Symfony Compatibility: Works with Symfony 4/5/6 (assuming AppKernel is still used or replaced with config/bundles.php in modern setups).
  • PHP Version: Likely requires PHP 7.4+ (common for modern Symfony apps), but this isn’t explicitly stated.
  • Database Agnosticism: The underlying library appears to use Doctrine DBAL, so it should work with any database supported by Symfony Doctrine.
  • Testing Overhead: Event Sourcing introduces complexity in testing (e.g., replaying events, handling concurrency). The bundle may not abstract this fully.

Technical Risk

  • Maturity Risk: Low stars/dependents suggest untested production use. Risk of hidden bugs in event persistence, event versioning, or concurrency handling.
  • Performance Unknowns: No benchmarks or guidance on event store scalability (e.g., how it handles millions of events).
  • Migration Complexity: If adopting ES mid-project, existing repositories may need refactoring to aggregates, increasing refactor effort.
  • Vendor Lock-in: Custom event formats or storage schemas could limit future flexibility.

Key Questions

  1. Event Storage Backend: How is the event store implemented (Doctrine, custom table, etc.)? Can it be swapped?
  2. Concurrency Control: How are conflicts resolved (e.g., optimistic/pessimistic locking)?
  3. Event Versioning: Does it support backward-compatible event schema changes?
  4. Projection Support: Are there built-in tools for materialized views (read models)?
  5. Symfony 6+ Compatibility: Does it work with modern Symfony (e.g., autowire: true, config/bundles.php)?
  6. Testing Strategy: How are event-sourced aggregates tested (e.g., replaying events in tests)?
  7. Performance: What are the expected write/read latencies for event storage?
  8. Alternatives: Why not use ProophEventStore, Laravel Event Sourcing, or Axon Framework?

Integration Approach

Stack Fit

  • Symfony Ecosystem: Ideal for Symfony apps already using Doctrine, Twig, or Symfony’s event system.
  • PHP Frameworks: Could be adapted for Lumen or Slim with minimal effort (Symfony components are framework-agnostic).
  • Non-Symfony PHP: Requires manual integration (e.g., configuring Doctrine DBAL separately).

Migration Path

  1. Assessment Phase:
    • Audit existing repositories to identify candidates for event sourcing (e.g., order processing, user profiles).
    • Validate compatibility with Symfony version and Doctrine setup.
  2. Pilot Implementation:
    • Start with a non-critical aggregate (e.g., a BlogPost with Published/Edited events).
    • Implement event store, event handlers, and aggregate reconstruction.
  3. Gradual Rollout:
    • Replace CRUD operations with event-based workflows.
    • Update read models (projections) incrementally.
  4. Testing:
    • Write event replay tests to verify aggregate state.
    • Test concurrency scenarios (e.g., two users editing the same aggregate).

Compatibility

  • Doctrine ORM: Works seamlessly if using Doctrine for event storage.
  • Custom Storage: May require extensions if using non-Doctrine databases (e.g., MongoDB, PostgreSQL JSONB).
  • Symfony Components: Leverages EventDispatcher, Serializer, and DependencyInjection.
  • Legacy Code: Existing services using repositories will need adaptation to aggregates.

Sequencing

  1. Infrastructure Setup:
    • Configure event store (Doctrine entity or custom table).
    • Set up event dispatcher and handlers.
  2. Domain Modeling:
    • Define aggregates and domain events.
    • Implement loadFromHistory() and apply() methods.
  3. Persistence Layer:
    • Create event store repository.
    • Configure event versioning (if needed).
  4. Read Models:
    • Build projections for query performance.
  5. API/CLI:
    • Expose event-sourced commands (e.g., app:replay-events).
  6. Monitoring:
    • Add logging for event publishing/applying.

Operational Impact

Maintenance

  • Event Schema Management:
    • Changes to events require backward-compatible versions (e.g., adding optional fields).
    • May need a migration strategy for existing events (e.g., using EventUpcaster).
  • Bundle Updates:
    • Low community activity increases risk of breaking changes.
    • May need forks for critical fixes.
  • Debugging:
    • Event sourcing adds complexity to debugging (e.g., tracing event flows).
    • Tools like Symfony Profiler or custom logging may be needed.

Support

  • Limited Community:
    • No official support channels (GitHub issues may go unanswered).
    • Documentation is minimal (RST format, unrendered).
  • Dependency Risks:
    • Relies on ddominio/event-sourcing, which also has low adoption.
  • Workarounds:
    • May need to extend the bundle for missing features (e.g., snapshotting).

Scaling

  • Event Store Performance:
    • Unclear how it handles high-throughput event writes (e.g., 10K+ events/sec).
    • No built-in partitioning or sharding for horizontal scaling.
  • Read Model Scaling:
    • Projections must be manually optimized (e.g., using read replicas or materialized views).
  • Concurrency:
    • Optimistic locking is common in ES, but pessimistic locks may be needed for high-contention scenarios.

Failure Modes

  • Event Loss:
    • If the event store fails during write, events may be lost (unless using transactions or a queue).
  • Inconsistent State:
    • Improper event handling (e.g., missing apply()) can corrupt aggregate state.
  • Replay Failures:
    • Schema changes or missing events during replay can break aggregates.
  • Performance Bottlenecks:
    • Loading large event histories for aggregates can cause timeouts.

Ramp-Up

  • Learning Curve:
    • Event Sourcing requires paradigm shift from CRUD (e.g., thinking in events, not commands).
    • Team may need training on DDD aggregates, event versioning, and projections.
  • Onboarding Time:
    • 1–2 weeks for a small team to implement a pilot.
    • 1–3 months for full project adoption (depends on complexity).
  • Documentation Gaps:
    • Lack of examples for real-world use cases (e.g., handling failures, retries).
    • No migration guide from traditional repositories to aggregates.
  • Tooling Needs:
    • May require custom scripts for event replay, auditing, or debugging.
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
emuniq/filament-browser-notifications
syriable/filament-translator
hungnm28/livewire-form
wenprise/eloquent
crudly/encrypted
fadion/bouncy
cuci/prototurk-sdk
gos/pubsub-router-bundle
cuci/prototurk-sdk-symfony
clementtalleu/easyadmin-markdown-bundle
codeflextech/permission-manager
karnoweb/livewire-datepicker
sayedenam/sayed-dashboard
milito/query-filter
apiboxsym/user-bundle
apiboxsym/health-check-bundle
jayeshmepani/jpl-moshier-ephemeris-php
elnasnato/laraliveui
labrodev/rest-sdk
sampaui/sampaui