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 Store Doctrine Adapter Laravel Package

prooph/event-store-doctrine-adapter

Doctrine DBAL adapter for Prooph Event Store. Stores and loads event streams using Doctrine connections, with support for transactional appends and stream persistence in relational databases. Useful for event-sourced PHP/Laravel apps needing DB-backed storage.

View on GitHub
Deep Wiki
Context7

Technical Evaluation

Architecture Fit

  • Event Sourcing Alignment: The package bridges Prooph’s event-sourcing model with Laravel’s Doctrine integration, making it a strong fit for applications requiring event-driven architecture with relational persistence. Ideal for CQRS or domain-driven design (DDD) use cases where events are core to business logic.
  • Laravel Compatibility: Leverages Doctrine DBAL (already common in Laravel via doctrine/dbal), reducing friction in adoption. Works well with Laravel’s database abstraction and migrations.
  • API Consistency: Maintains Prooph’s event store API, ensuring compatibility with existing Prooph-based event-sourcing logic.

Integration Feasibility

  • Low-Coupling Design: The adapter abstracts persistence details, allowing seamless integration with Prooph’s event store without modifying core business logic.
  • Doctrine Integration: Since Laravel often uses Doctrine DBAL (e.g., for Eloquent under the hood or via spatie/laravel-doctrine-orm), this package fits naturally into existing database workflows.
  • Schema Flexibility: Supports custom table layouts and serialization, accommodating Laravel’s schema conventions (e.g., snake_case naming, migrations).

Technical Risk

  • Stale Package: Last release in 2016 raises concerns about:
    • Compatibility with modern PHP/Laravel/Doctrine: May require patches for PHP 8.x, Laravel 10+, or Doctrine 3.x.
    • Security: No recent updates could imply unpatched vulnerabilities (though Prooph’s core may still be secure).
    • Maintenance: Lack of active development may limit long-term support.
  • Transaction Handling: While advertised as transaction-safe, real-world testing may reveal edge cases (e.g., nested transactions, deadlocks) in Laravel’s context.
  • Performance: Event sourcing in RDBMS can be write-heavy; benchmarking is critical for high-throughput apps.

Key Questions

  1. Compatibility:
    • Does the package support Doctrine DBAL 3.x and PHP 8.1+? If not, what backporting efforts are needed?
    • Are there known conflicts with Laravel’s query builder or Eloquent?
  2. Functional Gaps:
    • Does it handle event versioning, metadata, or projections natively? If not, how will these be managed?
    • Is event replay optimized for Laravel’s caching (e.g., Redis) or query builder?
  3. Alternatives:
    • Would a custom Doctrine repository or Laravel’s native event system suffice for simpler needs?
    • Are there newer packages (e.g., spatie/laravel-event-sourcing) that offer better Laravel integration?
  4. Testing:
    • How would you validate transaction integrity in Laravel’s context (e.g., with DB::transaction)?
    • Are there load-testing scenarios to assess performance under high event volumes?

Integration Approach

Stack Fit

  • Laravel + Doctrine DBAL: The package is a drop-in replacement for Prooph’s default storage backends, requiring only:
    • prooph/event-store (core event store).
    • prooph/event-store-doctrine-adapter (this package).
    • doctrine/dbal (already included in Laravel via illuminate/database).
  • Optional Add-ons:
    • Doctrine ORM: If using spatie/laravel-doctrine-orm, the adapter could extend to ORM-based persistence.
    • Laravel Caching: Integrate with Laravel’s cache (e.g., Redis) for event stream metadata or projections.

Migration Path

  1. Assessment Phase:
    • Audit existing event-sourcing logic for Prooph compatibility.
    • Verify Doctrine DBAL version and Laravel compatibility.
  2. Setup:
    • Install dependencies:
      composer require prooph/event-store prooph/event-store-doctrine-adapter doctrine/dbal
      
    • Configure the adapter in Laravel’s service provider:
      $eventStore = new \Prooph\EventStore\EventStore(
          new \Prooph\EventStore\Doctrine\EventStoreAdapter($dbalConnection)
      );
      
    • Publish migrations for event store tables (or use Laravel’s migrate).
  3. Incremental Rollout:
    • Start with non-critical streams to test performance and correctness.
    • Gradually replace in-memory or file-based event storage.

Compatibility

  • Database Support: Works with any DBAL-supported RDBMS (MySQL, PostgreSQL, SQLite, etc.), aligning with Laravel’s multi-database support.
  • Schema Customization: Adapt table names/columns via Doctrine’s SchemaManager or Laravel’s migrations.
  • Serialization: Supports custom serializers (e.g., JSON, MessagePack) via Prooph’s EventSerializer interface.

Sequencing

  1. Phase 1: Core Integration
    • Replace Prooph’s default storage with the Doctrine adapter.
    • Validate CRUD operations (append, load, search).
  2. Phase 2: Advanced Features
    • Implement event projections (e.g., materialized views).
    • Add Laravel-specific optimizations (e.g., caching, query scopes).
  3. Phase 3: Observability
    • Instrument with Laravel’s logging or monitoring (e.g., Sentry).
    • Set up database health checks (e.g., table bloat, lock contention).

Operational Impact

Maintenance

  • Dependency Risks:
    • Stale Package: Requires proactive monitoring for Doctrine/Prooph updates. Consider forking or maintaining a patched version.
    • Documentation Gaps: Lack of recent updates may necessitate reverse-engineering or community contributions.
  • Laravel-Specific Tasks:
    • Migrations: Event store schema changes must align with Laravel’s migration system.
    • Configuration: Centralize Doctrine DBAL settings (e.g., in config/database.php).

Support

  • Troubleshooting:
    • Debugging may require familiarity with Doctrine DBAL internals and Prooph event store.
    • Limited community support due to inactivity; rely on Prooph’s core docs or Laravel Doctrine communities.
  • Vendor Lock-In:
    • Tight coupling to Prooph’s event store API may complicate future migrations to other event-sourcing libraries.

Scaling

  • Performance Bottlenecks:
    • Write Scaling: Event appends are append-only; test under load to avoid table bloat or lock contention.
    • Read Scaling: Stream loading may benefit from read replicas or caching (e.g., Laravel’s cache or Redis).
  • Database Optimization:
    • Use indexes on stream_name and event_id for fast lookups.
    • Consider partitioning for large event streams (e.g., by stream_name).

Failure Modes

  • Data Corruption:
    • Risk of inconsistent state if transactions fail mid-append. Mitigate with:
      • Laravel’s DB::transaction().
      • Prooph’s built-in transaction middleware.
  • Downtime:
    • Database outages could halt event processing. Implement:
      • Retry logic (e.g., Laravel’s retry helper).
      • Dead-letter queues for failed events.
  • Schema Drift:
    • Manual schema changes (e.g., adding columns) may break migrations. Use Laravel’s schema builder for consistency.

Ramp-Up

  • Learning Curve:
    • Prooph Concepts: Requires understanding of event streams, aggregates, and event sourcing.
    • Doctrine DBAL: Familiarity with DBAL’s Connection and SchemaManager helps.
  • Onboarding Steps:
    1. Proof of Concept: Test with a single aggregate root.
    2. Team Training: Document Prooph/Doctrine patterns for developers.
    3. CI/CD Integration: Add tests for event store operations (e.g., using Laravel’s Pest or PHPUnit).
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