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

Ddd Symfony Bridge Laravel Package

becklyn/ddd-symfony-bridge

View on GitHub
Deep Wiki
Context7

Technical Evaluation

Architecture Fit

  • DDD Alignment: The package is a perfect fit for Laravel applications adopting Domain-Driven Design (DDD), particularly those requiring aggregates, events, and commands. It bridges Laravel’s simplicity with Symfony’s mature DDD tooling (e.g., becklyn/ddd-core and becklyn/ddd-doctrine-bridge), enabling:
    • Aggregate roots with invariant enforcement.
    • Event sourcing via Doctrine-backed event store.
    • CQRS with separate read/write models.
  • Symfony/Laravel Hybrid: While Laravel lacks native DDD support, this package allows leveraging Symfony’s dependency injection, event system, and Doctrine without full Symfony adoption. Ideal for teams using Laravel for APIs but needing DDD rigor.
  • Event-Driven Architecture (EDA): SimpleBus provides a synchronous command bus and asynchronous event bus, supporting:
    • Event subscribers for reactive programming.
    • Command handlers for decoupled business logic.
  • Laravel-Specific Considerations:
    • Laravel’s service container is compatible with Symfony’s DI (via Symfony\Component\DependencyInjection).
    • Doctrine ORM can be integrated via Laravel’s Doctrine packages (e.g., fruitcake/laravel-doctrine).
    • Artisan commands and routing remain Laravel-native, avoiding Symfony’s kernel overhead.

Integration Feasibility

  • High Feasibility for Laravel:
    • Composer Integration: Simple composer require with no Laravel-specific conflicts.
    • Service Registration: Laravel’s autowiring and tagging (e.g., *Subscriber, *Handler) align with Symfony’s conventions.
    • Doctrine Compatibility: Laravel’s Doctrine integration (e.g., fruitcake/laravel-doctrine) supports the event store migrations.
    • Event Dispatching: Laravel’s event system can proxy to SimpleBus’s event bus with minimal glue code.
  • Potential Challenges:
    • Symfony-Specific Assumptions: Some features (e.g., AggregateIdParamConverter) assume Symfony’s request handling. Laravel would need custom middleware or converters.
    • Event Store Migrations: Requires Doctrine migrations, which may need adaptation for Laravel’s schema management (e.g., migrations:run vs. Symfony’s doctrine:migrations:migrate).
    • Enum Serialization: Laravel’s native enum support (PHP 8.1+) may conflict with Symfony’s BackedEnumNormalizer. Custom serializers may be needed.

Technical Risk

Risk Area Severity Mitigation
Symfony-Laravel DI Conflicts Medium Use Laravel’s Symfony\DependencyInjection facade or isolate DDD services in a sub-container.
Doctrine Migration Issues High Test migrations in a Laravel environment; use fruitcake/laravel-doctrine for compatibility.
Event Bus Latency Low SimpleBus is synchronous by default; async support requires additional middleware (e.g., Symfony\Component\Messenger).
Enum Serialization Medium Override Symfony’s normalizers with Laravel-compatible versions.
Lack of Laravel Docs High Build internal runbooks for Laravel-specific configurations (e.g., Artisan commands for event store).
Vendor Lock-in Low Core DDD patterns (events, commands) are portable; only SimpleBus/Doctrine integrations are locked.

Key Questions for TPM

  1. DDD Maturity:

    • Does the team have experience with aggregates, invariants, and event storming? If not, budget for training or hire a DDD coach.
    • Are bounded contexts clearly defined, or will this package force premature modularization?
  2. Laravel-Symfony Hybrid:

    • Is the team comfortable with Symfony’s DI and Doctrine in a Laravel app? If not, consider a full Symfony migration.
    • Will the event store be the sole database, or will it coexist with Laravel’s Eloquent? (Risk of schema conflicts.)
  3. Performance:

    • Will the synchronous command bus cause bottlenecks for high-throughput APIs? (Consider Symfony\Component\Messenger for async.)
    • Are microsecond timestamps (Oracle-specific) needed, or can UTC timestamps suffice?
  4. Long-Term Maintenance:

    • The package is actively maintained (last release: 2026), but Laravel’s ecosystem moves faster. Will the team monitor for Symfony/Laravel compatibility gaps?
    • Are there alternatives (e.g., spatie/laravel-event-sourcing, asgrim/laravel-event-sourcing) that better fit Laravel’s native patterns?
  5. Testing:

    • How will event replay tests (e.g., rebuilding aggregates from events) be integrated into Laravel’s testing suite (Pest/PHPUnit)?
    • Are there mocking challenges for SimpleBus’s command/event buses in unit tests?

Integration Approach

Stack Fit

Laravel Component Package Integration Compatibility Notes
Service Container Uses Symfony’s DI under the hood; Laravel’s container is compatible via symfony/dependency-injection. Avoid conflicts by namespacing DDD services (e.g., App\Ddd\).
Doctrine ORM Requires fruitcake/laravel-doctrine for Laravel integration. Event store migrations must be adapted for Laravel’s Schema builder.
Event System Laravel’s events can dispatch to SimpleBus’s event bus via a listener. Custom event mapper needed to convert Laravel’s Illuminate\Events\Dispatcher to SimpleBus.
Routing/HTTP Symfony’s AggregateIdParamConverter may not work natively; use Laravel’s route model binding. Create custom middleware to bridge Symfony’s converters to Laravel’s.
Artisan Commands Package provides Symfony-style CLI commands (e.g., doctrine:migrations:migrate). Override or alias commands in app/Console/Kernel.php.
Validation Uses Symfony’s validator; Laravel’s Illuminate\Validation can coexist. No conflicts if DDD validation is scoped to domain layers.
Caching Doctrine cache is optional; Laravel’s cache (Redis/Memcached) can be configured. Replace doctrine/cache with Laravel’s cache adapter.

Migration Path

  1. Phase 1: Proof of Concept (2–4 weeks)

    • Goal: Validate DDD integration in a single bounded context (e.g., Order domain).
    • Steps:
      1. Install becklyn/ddd-symfony-bridge, becklyn/ddd-core, and becklyn/ddd-doctrine-bridge.
      2. Set up Doctrine in Laravel via fruitcake/laravel-doctrine.
      3. Implement an aggregate root (e.g., Order) with events and commands.
      4. Test event sourcing by replaying events to rebuild an aggregate.
      5. Benchmark performance vs. Eloquent for CRUD operations.
    • Success Criteria:
      • Aggregate invariants enforced correctly.
      • Events persisted to the event store without errors.
      • Commands handled without DI conflicts.
  2. Phase 2: Core Integration (4–8 weeks)

    • Goal: Integrate event bus, command bus, and event store into the Laravel app.
    • Steps:
      1. Configure SimpleBus bundles in Laravel’s config/bundles.php (or equivalent).
      2. Set up event subscribers and command handlers (autoload via *Subscriber, *Handler).
      3. Migrate the event store schema using Laravel’s Doctrine migrations.
      4. Replace Eloquent models with DDD aggregates where applicable.
      5. Implement CQRS by adding read models (e.g., Laravel’s Eloquent for queries).
    • Challenges:
      • Resolve Symfony-Laravel DI conflicts by isolating DDD services.
      • Adapt Doctrine migrations to Laravel’s schema management.
  3. Phase 3: Full Adoption (8–12 weeks)

    • Goal: Migrate remaining domains to DDD and decommission legacy monolithic services.
    • Steps:
      1. Gradually replace controllers with command handlers.
      2. Replace Eloquent events with domain events (e.g., OrderCreated instead of created: order).
      3. Implement event listeners for cross-context communication.
      4. Add testing for event replay and command validation.
    • Success Criteria:
      • 80% of business logic migrated to DDD aggregates.
      • Event store audits match legacy logs.
      • Performance degradation <10% vs. Eloquent.

**

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.
besmartand-pro/php-quality-config
sentix/ai-chatbot
codifyo/ts-generator-bundle
mintobit/jobqueue
a4sex/maintenance-bundle
a4sex/entity-date-update
a4sex/client-identifier
a4sex/base-utilites
a4sex/key-value-storage
a4sex/micro-status
chilldev/dependency-injection-extra
datinglibre/datinglibre-app-api
biberltd/corebundle
bricre/symfony-bundle-test
biberltd/logbundle
dominium/http-adapter-bundle
dominium/google-analytics
a4sex/auto-clean-entity
christhompsontldr/laravel-inky
spatie/mailcoach-vapor