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 Symfony Bundle Laravel Package

prooph/event-store-symfony-bundle

Symfony bundle integrating Prooph Event Store into Symfony apps. Provides configuration, services, and tooling to use Prooph’s event store with Symfony. Includes migration guidance, docs build instructions, and community support links.

View on GitHub
Deep Wiki
Context7

Technical Evaluation

Architecture Fit

  • Event Sourcing Alignment: The package remains a Symfony Bundle for prooph/event-store, maintaining alignment with Event Sourcing, CQRS, and DDD architectures. The update to Symfony matrix testing (v0.11.2) ensures compatibility with Symfony 6.4+ and PHP 8.2+, reinforcing its fit for modern PHP ecosystems.
    • Key Strengths:
      • Temporal queries, auditability, and event-driven workflows remain core use cases.
      • Polyglot persistence (Doctrine DBAL, MongoDB, PostgreSQL JSONB) unchanged.
    • Laravel Synergy: Still requires Symfony integration (via bridge or microkernel), but the updated Symfony matrix testing reduces compatibility risks for Laravel projects using Symfony components.

Integration Feasibility

  • Symfony Compatibility:
    • Now explicitly tested against Symfony 6.4+ (via matrix testing), aligning with Laravel 10+ (which uses Symfony 6+ components).
    • PHP 8.2+ requirement (implicit from Symfony 6.4+) may necessitate Laravel upgrades if using older versions (e.g., Laravel 9.x).
  • Laravel Adaptability:
    • No breaking changes to core functionality, but the Symfony matrix testing implies stricter dependency validation.
    • Event Dispatching: Laravel’s Events system can still coexist, but prooph’s event store should remain the single source of truth to avoid duplication.
  • Database Schema: Unchanged—still requires a dedicated event table or NoSQL backend.

Technical Risk

Risk Area Severity Mitigation Strategy
Symfony 6.4+ Dependency Medium Ensure Laravel stack (or Symfony bridge) supports Symfony 6.4+. Use symfony/ux or spatie/laravel-symfony for integration.
PHP 8.2+ Requirement Medium Upgrade Laravel to 10.x (or patch older versions with PHP 8.2 compatibility).
Testing Matrix Shift Low No functional changes; validates stability for newer Symfony versions.
Debugging Complexity Medium Leverage prooph/event-store-debugger alongside Laravel’s Pest/PHPUnit.
Vendor Lock-in Low prooph remains PSR-compliant; interfaces can be mocked for testing.

Key Questions

  1. Symfony/Laravel Stack Alignment:
    • Are you using Laravel 10+ or a Symfony 6.4+ bridge? Confirm compatibility before integration.
  2. PHP Version Upgrade:
    • Can your Laravel project support PHP 8.2+? If not, evaluate alternatives like prooph/event-store (non-Symfony).
  3. Event Schema Evolution:
    • With stricter Symfony testing, ensure your event payloads remain backward-compatible.
  4. Laravel-Symfony Integration:
    • Will you use a Symfony microkernel or proxy calls? Document the trade-offs for maintenance.
  5. Existing Event System:
    • How will you migrate from Laravel Events to prooph without duplication? Plan for a phased cutover.
  6. Testing Strategy:
    • Update CI to test against Symfony 6.4+ if using the Bundle directly.

Integration Approach

Stack Fit

  • Core Stack:
    • PHP 8.2+ (required by Symfony 6.4+).
    • Symfony 6.4+ (native support) or Laravel 10+ (with adaptation).
    • Database: PostgreSQL (recommended for JSONB), MySQL (Doctrine DBAL), or MongoDB.
  • Laravel-Specific Considerations:
    • Service Providers: Bind prooph components in Laravel’s AppServiceProvider:
      $this->app->bind(EventStore::class, fn() => new PdoEventStore(
          new Connection($this->app['db']->connection('pgsql')->getPdo())
      ));
      
    • Configuration: Override Symfony defaults in config/prooph.php:
      'prooph_event_store' => [
          'event_store' => [
              'connection' => 'pgsql',
          ],
      ],
      
    • Messenger Integration: Bridge Laravel’s bus with prooph’s EventBus via a message handler adapter:
      $this->app->bind(\Symfony\Component\Messenger\MessageBusInterface::class, fn() =>
          new CommandBus($this->app->make(EventStore::class))
      );
      
  • Alternatives:
    • For minimal Symfony dependency, use prooph/event-store directly (without the Bundle) and manually wire components.

Migration Path

  1. Assessment Phase:
    • Audit event-like logic (e.g., Laravel Jobs, Observers) for prooph compatibility.
    • Identify candidate aggregates (e.g., Order, User) with high write complexity.
  2. Proof of Concept (PoC):
    • Implement a single aggregate (e.g., Order) with prooph’s AggregateRoot.
    • Test event replay, Laravel integration, and Symfony 6.4+ compatibility.
  3. Incremental Rollout:
    • Phase 1: Replace write-heavy services (e.g., commands → prooph events).
    • Phase 2: Migrate read models to query the event store (e.g., Laravel Eloquent projections).
    • Phase 3: Deprecate legacy event systems (e.g., Laravel Events).
  4. Data Migration:
    • Backfill existing data into the event store using a Laravel Artisan command:
      php artisan prooph:migrate-events --from=legacy_table --to=event_store
      

Compatibility

Component Compatibility Notes
Laravel Events Can coexist but should delegate to prooph to avoid inconsistency.
Laravel Queues prooph’s EventBus can dispatch events to queues via Symfony Messenger.
Doctrine ORM Avoid mixing Doctrine entities and event-sourced aggregates (separate concerns).
API Platform prooph can power event-driven APIs (e.g., GraphQL subscriptions with Laravel Echo).
Testing Use prooph/testing alongside Laravel’s Pest/PHPUnit for event assertions.

Sequencing

  1. Setup:
    • Install with Composer:
      composer require prooph/event-store-symfony-bundle prooph/event-store-pdo
      
    • Configure config/packages/prooph_event_store.yaml (or config/prooph.php in Laravel).
  2. Aggregate Design:
    • Define aggregates with RecordedEvents:
      class OrderAggregate extends AggregateRoot {
          public function apply(OrderCreated $event) { ... }
      }
      
  3. Event Store Configuration:
    • Register the EventStore in Laravel’s AppServiceProvider:
      $this->app->bind(EventStore::class, fn() => new PdoEventStore(
          new Connection($this->app['db']->connection()->getPdo())
      ));
      
  4. Command Handling:
    • Use prooph’s CommandBus to handle domain commands (e.g., CreateOrderCommand).
  5. Query Layer:
    • Build read models (e.g., Laravel Eloquent or custom projections) to materialize views.
  6. Integration:
    • Bridge Laravel’s Event system to prooph (e.g., dispatch Laravel events → prooph events via a listener).

Operational Impact

Maintenance

  • Pros:
    • Stricter Symfony testing reduces runtime compatibility issues.
    • Decoupled components allow backend swaps (e.g., PostgreSQL → MongoDB).
  • Cons:
    • Symfony 6.4+ dependency may require Laravel upgrades.
    • Event schema management demands discipline (use JSON Schema for contracts).
  • Best Practices:
    • Use feature flags for gradual rollout.
    • Document event versioning strategy (e.g., semantic versioning in payloads).

Support

  • Debugging:
    • prooph’s EventStoreDebugger + Laravel’s Pest for assertions.
    • Log prooph events via Laravel’s Monolog:
      $this->app['monolog']->pushHandler(new StreamHandler(storage_path('logs/prooph.log')));
      
  • Monitoring:
    • Track event store latency, failed projections, and command success rates with Laravel Horizon.
    • Use Symfony Profiler (if embedded
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.
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
babelqueue/php-sdk
facebook/capi-param-builder-php
babelqueue/symfony
hamzi/corewatch
minionfactory/raw-hydrator
hexters/coinpayment
rjcodes/rjcms
act-training/laravel-permissions-manager