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

Eventsauce Bundle Laravel Package

andreo/eventsauce-bundle

View on GitHub
Deep Wiki
Context7

Technical Evaluation

Architecture Fit

  • Event-Driven Architecture (EDA) Alignment: The package leverages EventSauce, a robust CQRS/ES framework, making it a strong fit for systems requiring event sourcing, projections, and reactive programming. It aligns well with Symfony’s messenger component for async processing, reducing coupling between services.
  • Symfony Ecosystem Compatibility: Deep integration with Doctrine DBAL/ORM, Symfony Messenger, and Monolog ensures seamless adoption in existing Symfony applications. The bundle abstracts low-level EventSauce complexity while exposing high-level abstractions (e.g., EventConsumer, MessageDispatcher).
  • Domain-Driven Design (DDD) Support: Features like Anti-Corruption Layer (ACL), Upcasting, and Snapshotting directly support DDD patterns, enabling bounded contexts, event versioning, and performance optimizations (e.g., snapshots for large aggregates).
  • Modularity: The bundle’s config-driven approach (e.g., message_dispatcher, snapshot) allows granular adoption—teams can enable only required features (e.g., Outbox for reliability without ACL).

Integration Feasibility

  • Low Friction for Symfony Apps: Minimal boilerplate (e.g., #[AsSyncMessageConsumer], #[AsEventSauceMessageHandler]) reduces onboarding time. Autoconfiguration via attributes or YAML tags simplifies setup.
  • Database Schema Management: Automatic migration generation for event stores/snapshots reduces manual SQL work. However, schema evolution (e.g., upcasting) requires explicit handling.
  • Messenger Integration: Tight coupling with Symfony Messenger enables async event processing, but requires configuring middleware order (e.g., handle_eventsauce_message must run after send_message).
  • Doctrine Dependency: While DBAL is required for storage, ORM integration is limited (e.g., no native Doctrine entity repositories for aggregates). Teams using Doctrine ORM may need custom adapters.

Technical Risk

  • Immaturity: 0 stars/dependents and minimal documentation signal unproven adoption. Risk of undiscovered bugs or breaking changes in early versions.
  • Complexity Overhead: Features like ACL, Upcasting, and Snapshotting introduce additional moving parts. Teams unfamiliar with EventSauce may struggle with:
    • Message translation (ACL).
    • Event versioning (Upcasting).
    • Snapshot strategies (conditional persistence).
  • Performance Trade-offs:
    • Snapshotting improves read performance but adds write overhead (e.g., snapshot storage).
    • Outbox pattern ensures reliability but requires separate consumers (e.g., andreo:eventsauce:message-outbox:consume).
  • Testing Challenges:
    • Event replayability (e.g., for projections) requires fixture setup.
    • Async consumers (Messenger) need integration tests with message queues.

Key Questions

  1. Adoption Readiness:
    • Does the team have experience with EventSauce or CQRS/ES? If not, budget for training/ramp-up.
    • Is the team comfortable with Symfony Messenger for async workflows?
  2. Database Strategy:
    • Will Doctrine DBAL suffice, or are custom adapters needed for ORM/other DBs?
    • How will schema migrations be managed in CI/CD (e.g., automated migration generation)?
  3. Reliability Requirements:
    • Is Outbox pattern critical for exactly-once processing? If so, plan for separate consumers and retries.
    • Are snapshots needed for performance? If yes, test snapshot size and conditional persistence logic.
  4. Monitoring:
    • How will event consumption failures (e.g., Messenger dead-letter queues) be monitored?
    • Are metrics needed for event throughput or ACL filtering?
  5. Long-Term Maintenance:
    • Who will maintain upcasters if event schemas evolve?
    • Is the team prepared for EventSauce version upgrades (e.g., PHP 8.2+ requirements)?

Integration Approach

Stack Fit

  • Symfony 6.2+: Native support for Symfony Messenger, Doctrine DBAL, and Monolog ensures compatibility. PHP 8.2 requirement may necessitate runtime upgrades.
  • Event-Driven Components:
    • Producers: Use EventSauce\EventSourcing\EventDispatcher to emit events (e.g., in domain services).
    • Consumers: Leverage Messenger for async processing or sync dispatchers for immediate reactions.
    • Projections: Build read models via EventConsumer classes (e.g., #[AsEventSauceMessageHandler]).
  • Database Layer:
    • Event Store: Single table per aggregate type (e.g., event_store) with JSON payloads.
    • Snapshots: Optional Doctrine-based snapshot store (snapshot_store).
    • Outbox: Separate table (message_outbox) for reliable async delivery.
  • Testing:
    • Unit Tests: Mock MessageDispatcher or use EventSauce’s test utilities.
    • Integration Tests: Test Messenger consumers with real queues (e.g., Doctrine transport).

Migration Path

  1. Assessment Phase:
    • Audit existing event-like logic (e.g., commands, services emitting logs) to identify aggregates and events.
    • Map current projections (e.g., database views, cron jobs) to EventSauce consumers.
  2. Incremental Adoption:
    • Phase 1: Replace synchronous event handlers with EventDispatcher + SyncMessageDispatcher.
    • Phase 2: Migrate async workflows to MessengerMessageDispatcher (requires middleware config).
    • Phase 3: Enable Outbox for critical paths (e.g., payments) and Snapshotting for performance-critical aggregates.
  3. Database Schema:
    • Generate initial migrations for event_store and snapshot_store (if used).
    • Use Upcasters to handle backward-compatible schema changes.
  4. Deprecation:
    • Gradually replace legacy event listeners with EventSauce consumers.
    • Deprecate direct database writes in favor of event emission.

Compatibility

  • Symfony Ecosystem:
    • Messenger: Works with all transports (Doctrine, AMQP, Redis), but middleware order is critical.
    • Doctrine: DBAL is required; ORM may need custom repositories for aggregates.
    • Monolog: Optional but recommended for Outbox logging.
  • Third-Party Packages:
    • andreo/eventsauce-messenger: Required for Messenger integration.
    • andreo/eventsauce-outbox: Required for Outbox pattern.
    • andreo/eventsauce-snapshotting: Required for Snapshotting.
  • Legacy Systems:
    • Anti-Corruption Layer (ACL) can translate legacy events to new schemas.
    • Message Decorators can enrich events before storage.

Sequencing

  1. Core Setup:
    • Install dependencies (andreo/eventsauce-bundle, andreo/eventsauce-messenger, etc.).
    • Configure bundles.php and config/packages/andreo_event_sauce.yaml.
  2. Event Store:
    • Define aggregate roots and events.
    • Generate and run migrations for event_store.
  3. Consumers:
    • Implement sync consumers (#[AsSyncMessageConsumer]) for immediate reactions.
    • Implement async consumers (#[AsEventSauceMessageHandler]) for Messenger.
  4. Reliability:
    • Enable Outbox and configure message-outbox:consume command.
    • Set up retries (e.g., ExponentialBackOffStrategy) for failed messages.
  5. Optimizations:
    • Enable Snapshotting for large aggregates.
    • Configure Upcasters for event versioning.
  6. Monitoring:
    • Add logging for event consumption.
    • Set up alerts for failed Outbox messages.

Operational Impact

Maintenance

  • Configuration-Driven: Changes to dispatchers, ACL rules, or snapshots require YAML/PHP updates (no runtime recompilation).
  • Upcasting: Requires manual upcaster classes for event schema changes. Automated migration generation helps but doesn’t eliminate manual review.
  • Dependency Updates:
    • EventSauce and Symfony version alignment is critical (e.g., PHP 8.2+).
    • Bundle updates may require
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.
comsave/common
alecsammon/php-raml-parser
chrome-php/wrench
lendable/composer-license-checker
typhoon/reflection
mesilov/moneyphp-percentage
mike42/gfx-php
bookdown/themes
aura/view
aura/html
aura/cli
povils/phpmnd
nayjest/manipulator
omnipay/tests
psr-mock/http-message-implementation
psr-mock/http-factory-implementation
psr-mock/http-client-implementation
voku/email-check
voku/urlify
rtheunissen/guzzle-log-middleware