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

Domain Events Bundle Laravel Package

andy-thorne/domain-events-bundle

View on GitHub
Deep Wiki
Context7

Technical Evaluation

Architecture Fit

  • Event-Driven Design: The package aligns well with Domain-Driven Design (DDD) principles, enabling event sourcing and CQRS patterns by decoupling event publishing from business logic.
  • Doctrine Integration: Seamlessly integrates with Doctrine ORM/ODM, leveraging post-flush lifecycle events to dispatch events asynchronously.
  • Messenger Component: Uses Symfony’s Messenger for transport, enabling scalable, decoupled event handling (e.g., via queues, AMQP, or HTTP).
  • Limitation: Archived status (no updates since 2022) may introduce compatibility risks with newer Symfony/Laravel versions.

Integration Feasibility

  • Symfony-Centric: Designed for Symfony, not Laravel. Laravel lacks native Doctrine ORM/ODM and Messenger support, requiring:
    • Doctrine ORM: Possible via doctrine/orm (Laravel 8+ supports Doctrine via laravel-doctrine).
    • Messenger: No direct Laravel equivalent; would need Laravel Queues (database/Redis) or third-party packages (e.g., spatie/laravel-messenger).
  • Event Dispatching: Laravel’s Event System (event(new MyEvent())) is simpler but lacks Doctrine-triggered events. This package’s post-flush hook would require custom Laravel Doctrine listeners.
  • Workaround: Could adapt the Messenger-based approach using Laravel Queues + custom Doctrine listeners, but not a drop-in solution.

Technical Risk

  • High Integration Effort:
    • Doctrine in Laravel: Non-trivial setup (e.g., laravel-doctrine compatibility, entity mapping).
    • Messenger Alternative: No native Laravel equivalent; would need queue-based event bus (e.g., illuminate\queue).
  • Maintenance Risk:
    • Archived Package: No guarantees for Symfony 6.4+/Laravel 10+ compatibility.
    • Lack of Dependents: No real-world adoption; potential hidden bugs or undocumented edge cases.
  • Performance Overhead:
    • Asynchronous events add latency and complexity (e.g., retries, dead-letter queues) if not configured properly.

Key Questions

  1. Why Symfony-Specific?
    • Is Laravel’s native event system insufficient? If so, what specific DDD/CQRS requirements justify this package?
  2. Doctrine Feasibility
    • Is Doctrine ORM/ODM a hard requirement, or could Laravel’s Eloquent + Queues suffice?
  3. Messenger Alternative
    • Would a custom Laravel Queue-based event bus (e.g., Event::dispatch()dispatch(new DomainEvent())) meet needs?
  4. Archived Package Risk
    • Are there active forks or modern alternatives (e.g., spatie/laravel-event-sourcing)?
  5. Event Sourcing Needs
    • Are events only for side effects (e.g., notifications) or critical for state (requiring strict ordering)?

Integration Approach

Stack Fit

  • Symfony: Native fit (Doctrine + Messenger).
  • Laravel:
    • Doctrine ORM: Possible via laravel-doctrine (but not recommended for most Laravel apps; Eloquent is preferred).
    • Messenger: No direct equivalent; alternatives:
      • Laravel Queues (illuminate\queue) for async dispatch.
      • Third-party packages (e.g., spatie/laravel-messenger for Symfony Messenger compatibility).
    • Event System: Laravel’s Event::dispatch() is simpler but lacks Doctrine-triggered events.

Migration Path

  1. Assess Requirements:
    • If Doctrine is mandatory, evaluate laravel-doctrine + custom Doctrine listeners.
    • If Eloquent is acceptable, use Laravel’s native events + queues.
  2. Prototype Integration:
    • Option A (Symfony-like):
      • Install laravel-doctrine + spatie/laravel-messenger.
      • Adapt the bundle’s Doctrine post-flush listener to Laravel.
    • Option B (Laravel-Native):
      • Use Eloquent observers or model events (created, updated).
      • Dispatch events via Event::dispatch() and handle with listeners.
  3. Transport Layer:
    • Replace Messenger with Laravel Queues (database/Redis) for async processing.
    • Example:
      // Instead of Messenger, use Laravel Queues
      event(new DomainEvent($entity));
      // Or via Doctrine listener:
      $entityManager->getEventManager()->addEventListener(
          \Doctrine\ORM\Events::postFlush,
          fn() => DomainEvent::dispatchAll()
      );
      

Compatibility

  • Doctrine: Laravel’s Eloquent is not ORM-compatible; Doctrine requires custom setup.
  • Messenger: No Laravel equivalent; queues are the closest alternative.
  • Symfony Version: Package targets Symfony 5.4/6.0; Laravel 10+ may need adapters (e.g., symfony/messenger bridge).

Sequencing

  1. Phase 1: Decide between Doctrine (high effort) or Eloquent (low effort).
  2. Phase 2: Implement event dispatching (Doctrine listeners or Eloquent observers).
  3. Phase 3: Set up async transport (Laravel Queues or custom bus).
  4. Phase 4: Test event ordering, retries, and failure handling.

Operational Impact

Maintenance

  • High Effort:
    • Doctrine in Laravel: Requires ongoing sync with laravel-doctrine updates.
    • Custom Listeners: Risk of breakage if Doctrine or Symfony Messenger APIs change.
  • Low Effort (Eloquent):
    • Laravel’s native events are well-supported and stable.
    • Queues are mature and easy to debug.

Support

  • Limited Ecosystem:
    • No Laravel-specific docs or community support.
    • Archived package: No official bug fixes; rely on community forks or custom patches.
  • Alternatives:
    • Laravel Event Sourcing: Packages like spatie/laravel-event-sourcing may offer better support.
    • Symfony Migration: Consider full Symfony stack if domain events are critical.

Scaling

  • Asynchronous Processing:
    • Pros: Decouples event handling (e.g., notifications, analytics).
    • Cons: Adds complexity (queue monitoring, retries, dead letters).
  • Laravel Queues:
    • Scalable with Redis/database drivers.
    • Monitoring: Use Laravel Horizon or third-party tools (e.g., RabbitMQ management).

Failure Modes

Risk Area Impact Mitigation Strategy
Doctrine Integration Events not fired due to misconfig Use laravel-doctrine + thorough testing.
Queue Failures Events lost or delayed Implement retry logic and dead-letter queues.
Symfony API Changes Bundle breaks in Laravel Abstract Symfony dependencies behind adapters.
Event Ordering Out-of-order processing Use transactional outbox pattern (e.g., store events in DB before commit).

Ramp-Up

  • Learning Curve:
    • High for Doctrine + Messenger in Laravel.
    • Moderate for Eloquent + Queues (familiar to Laravel devs).
  • Onboarding Time:
    • Symfony-like setup: 2–4 weeks (prototype + debugging).
    • Laravel-native: 1–2 weeks (if using Eloquent).
  • Team Skills:
    • Requires Symfony/Messenger knowledge if going the Doctrine route.
    • Laravel devs can handle queues/events with minimal training.
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.
daikazu/eloquent-salesforce-objects
unseen-codes/chat
romalytar/yammi-jobs-monitoring-laravel
kisame76/filament-db-table-state
nqxcode/laravel-lucene-search
dpfx/laravel-livewire-wizards
workos/workos-php-laravel
sofa/laravel-global-scope
nawasara/auth-primitives
adhocrat-io/arkhe-main
make-dev/orca-harpoon
itsemon245/lamet
baks-dev/dashboard
amoifr/pickle-panther-bundle
make-dev/orca
dmstr/symfony-system-resources-bundle
dmstr/symfony-job-queue-bundle
dmstr/openapi-json-schema-bundle
dmstr/keycloak-security-bundle
dmstr/doctrine-audit-log-bundle