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

Api Platform Event Engine Bundle Laravel Package

arnedesmedt/api-platform-event-engine-bundle

View on GitHub
Deep Wiki
Context7

Technical Evaluation

Architecture Fit

  • Event-Driven CQRS Alignment: The package bridges API Platform (REST/GraphQL API layer) with Event Engine (CQRS/Event Sourcing), enabling a clean separation between read/write models. This aligns well with domain-driven design (DDD) and event-driven architectures, particularly for systems requiring auditability, eventual consistency, or complex business workflows.
  • Aggregate-Centric Design: Forces explicit modeling of aggregates (via AggregateRoot) and commands (via AggregateCommand), which enforces bounded context boundaries and reduces accidental coupling between API endpoints and business logic.
  • Schema-Driven Contracts: Leverages JSON Schema (JsonSchemaAwareRecord) for both commands and state, ensuring machine-readable contracts between API Platform and Event Engine. This is valuable for API-first and microservices architectures where schema validation is critical.

Integration Feasibility

  • API Platform Compatibility: Works with API Platform 3.x, which is stable but not the latest (current is 4.x). Backward compatibility risks exist if upgrading API Platform later.
  • Event Engine Dependency: Tightly coupled with arnedesmedt/event-engine-symfony-bundle (v0.8.0), which may introduce vendor lock-in or maintenance overhead if the upstream bundle evolves.
  • Symfony Ecosystem: Assumes a Symfony-based stack (e.g., dependency injection, messenger component). Non-Symfony PHP projects (e.g., pure Laravel) would require significant adaptation.
  • Laravel-Specific Challenges:
    • No Native Laravel Support: The bundle is Symfony-first, requiring workarounds (e.g., Symfony’s Bundle system, ContainerInterface) in Laravel.
    • Event Dispatching: Laravel’s event system differs from Symfony’s Messenger/EventDispatcher. Mapping API Platform operations to Event Engine commands would need custom middleware or listeners.
    • Serialization: Laravel uses Laravel Serialization (e.g., Illuminate\Support\Collection), while this bundle relies on team-blue/php-json-immutable-objects. Potential serialization mismatches could arise.

Technical Risk

Risk Area Severity Mitigation Strategy
API Platform Version High Pin to exact versions of api-platform/core to avoid breaking changes.
Symfony Dependency High Abstract Symfony-specific components (e.g., ContainerInterface) behind interfaces.
Event Engine Maturity Medium Evaluate event-engine-symfony-bundle’s long-term viability and community support.
Schema Rigidity Medium Ensure JSON Schema definitions are versioned and backward-compatible.
Performance Overhead Low Benchmark command/aggregate processing latency under load.
Debugging Complexity Medium Implement structured logging for event-command mappings and aggregate state.

Key Questions

  1. Why Event Engine?

    • What specific CQRS/Event Sourcing requirements justify this over native Laravel solutions (e.g., laravel-echo, spatie/laravel-event-sourcing)?
    • Is the team already invested in the Event Engine ecosystem?
  2. Laravel Adaptation Effort

    • How will Symfony’s Bundle system be replaced in Laravel? (e.g., via service providers, package wrappers)
    • Are there alternative Laravel packages (e.g., spatie/laravel-cqrs) that could achieve similar goals with less friction?
  3. Aggregate Design

    • How will aggregate roots and commands map to existing Laravel models/resources?
    • Will this introduce duplication (e.g., separate API Platform entities vs. Event Engine aggregates)?
  4. Operation Mapping

    • How will API Platform’s operations (e.g., POST /orders, PATCH /orders/{id}) be explicitly mapped to Event Engine commands?
    • What happens with unmapped operations (e.g., bulk actions, custom API routes)?
  5. Error Handling & Rollback

    • How will failed commands or invalid state transitions be handled? (e.g., retries, compensating events)
    • Does Event Engine support saga patterns for distributed transactions?
  6. Testing Strategy

    • How will event-command flows be tested? (e.g., unit tests for aggregates, integration tests for API ↔ Event Engine)
    • Are there mocking challenges given the tight coupling with Event Engine?
  7. Long-Term Maintenance

    • Who will maintain this integration if the upstream bundles (event-engine-symfony-bundle) evolve?
    • Is there a fallback plan if the package becomes unmaintained?

Integration Approach

Stack Fit

Component Laravel Equivalent/Alternative Compatibility Notes
API Platform api-platform/core (Laravel bridge exists) Use api-platform/laravel for Laravel integration.
Event Engine arnedesmedt/event-engine-symfony-bundle No direct Laravel port; requires abstraction layer (e.g., custom service container bindings).
Messenger Laravel’s Illuminate\Bus or Laravel\Horizon Event Engine commands may need to be adapted to Laravel queues.
JSON Schema spatie/laravel-json-schema or zircote/swagger-php Ensure schema validation aligns between API Platform and Event Engine.
Aggregate Root Laravel models + spatie/laravel-event-sourcing Could replace with Laravel’s native event system if Event Engine is overkill.
Command Bus laravel-zero/framework or custom middleware API Platform operations would dispatch commands via Laravel middleware or API resource hooks.

Migration Path

  1. Assessment Phase

    • Audit existing API Platform resources and business workflows to identify aggregate boundaries.
    • Map current CRUD operations to potential Event Engine commands/queries.
  2. Proof of Concept (PoC)

    • Implement a single aggregate (e.g., Order) with:
      • API Platform resource → Event Engine command mapping.
      • JSON Schema validation for commands/state.
    • Test with Laravel’s event system as a proxy for Event Engine.
  3. Abstraction Layer

    • Create a Laravel-specific wrapper for event-engine-symfony-bundle:
      • Replace Bundle with a service provider.
      • Adapt ContainerInterface to Laravel’s Illuminate\Container.
      • Use Laravel’s queue system for command dispatching.
    • Example:
      // app/Providers/EventEngineServiceProvider.php
      public function register()
      {
          $this->app->singleton(EventEngine::class, function ($app) {
              return new EventEngine(
                  $app->make(CommandBus::class), // Laravel queue-based
                  $app->make(Store::class)       // Custom store adapter
              );
          });
      }
      
  4. Incremental Rollout

    • Phase 1: Migrate write-heavy aggregates (e.g., orders, users) first.
    • Phase 2: Gradually replace read models with projections from Event Engine.
    • Phase 3: Deprecate direct model updates in favor of command-based mutations.
  5. Fallback Strategy

    • If integration proves too cumbersome, consider:
      • Hybrid approach: Use Event Engine for critical aggregates, keep others in Laravel.
      • Alternative packages: Evaluate spatie/laravel-cqrs or laravel-echo for simpler event-driven needs.

Compatibility

Concern Solution
Symfony vs. Laravel DI Use Laravel’s bind() method to resolve Symfony interfaces.
Messenger vs. Queues Route Event Engine commands to Laravel’s dispatch() or Bus::dispatch().
API Platform Operations Use API Platform’s ApiResource hooks (e.g., postPersist, postUpdate) to trigger commands.
JSON Schema Validation Reuse api-platform/core’s schema definitions or sync with Event Engine’s schemas.
Testing Mock EventEngine interface or use Laravel’s MocksWithinGroups for integration tests.

Sequencing

  1. Setup Dependencies
    • Install api-platform/laravel and `arnedesmedt/event-engine
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.
directorytree/privacy-filter-classifier
directorytree/privacy-filter
datacore/hub-sdk
develia/commons
cuci/prototurk-sdk
cuci/prototurk-sdk-symfony
develia/geo-bundle
dreamzy/livewire-charts
touchestate-sdk/php-sdk
22h/doctrine-garbage-collection-bundle
agtp/agtp-php
agtp/mod-php
splash/sonata-admin
splash/metadata
splash/openapi
splash/scopes
splash/toolkit
testo/output-teamcity
testo/bridge-symfony
spatie/flare-daemon-runtime