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

Symfony Boilerplate Laravel Package

aljerom/symfony-boilerplate

A lightweight Symfony boilerplate to kickstart new projects with a ready-to-use structure, common configuration, and sensible defaults. Helps you bootstrap development faster and keep your app setup consistent across environments.

View on GitHub
Deep Wiki
Context7

Technical Evaluation

Architecture Fit

  • DDD/CQRS Alignment: The package aligns well with Laravel projects adopting Domain-Driven Design (DDD) or Command Query Responsibility Segregation (CQRS) patterns, particularly if the team is already familiar with Symfony’s ecosystem (e.g., Doctrine, Messenger, EventDispatcher). However, Laravel’s native ecosystem (e.g., Laravel Events, Queues, or packages like spatie/laravel-query-builder) may offer tighter integration without abstraction overhead.
  • Modularity: The boilerplate’s focus on buses (command/query), domain events, and request resolvers suggests a highly modular architecture, which could be beneficial for large-scale Laravel applications with complex workflows. However, Laravel’s built-in Service Container and Events system may reduce the need for custom bus implementations.
  • HTTP/Console Subscribers: The inclusion of HTTP and console subscribers (e.g., for CLI-driven workflows) is valuable for Laravel, where Artisan commands and API-driven interactions are core. This could streamline event-driven CLI operations (e.g., cron jobs, migrations, or background tasks).

Integration Feasibility

  • Symfony vs. Laravel Ecosystem:
    • The package is Symfony-centric, relying on components like Symfony\Component\Messenger, Symfony\Component\EventDispatcher, and Symfony\Component\HttpKernel. Laravel has parallel but distinct implementations (e.g., Illuminate\Bus, Illuminate\Events, Illuminate\Http\Kernel).
    • Key Challenges:
      • Messenger vs. Queues: Laravel’s Illuminate\Queue (with jobs) is the de facto standard for messaging, while Symfony’s Messenger is more feature-rich (e.g., middleware, transports). Migrating between them may require significant refactoring.
      • EventDispatcher: Laravel’s Events system is simpler and more tightly integrated with Eloquent. Symfony’s EventDispatcher is more low-level.
      • Request Resolvers: Laravel’s Service Container and Route Model Binding may obviate the need for custom request resolvers.
    • Workarounds:
      • Use adapter packages (e.g., symfony/messenger for Laravel via php-http/dispatcher or custom bridges).
      • Abstract Symfony-specific logic behind interfaces to allow Laravel-native implementations.
  • Database/ORM Compatibility:
    • The boilerplate likely assumes Doctrine ORM, while Laravel uses Eloquent. Migrating between them is non-trivial (e.g., repositories, entity mappings).
    • Solution: Use abstract repository patterns or Doctrine Bridge for Laravel (doctrine/orm + illuminate/database).

Technical Risk

  • High Abstraction Overhead:
    • Introducing a Symfony boilerplate into Laravel risks over-engineering for projects not heavily invested in DDD/CQRS. The learning curve for developers unfamiliar with Symfony’s patterns (e.g., CommandBus, EventBus) could slow down development.
  • Maintenance Burden:
    • The package is unmaintained (0 stars, no dependents) and lacks Laravel-specific optimizations. Future updates or bug fixes would require forking or custom patches.
  • Performance Implications:
    • Symfony’s Messenger and EventDispatcher may introduce additional layers of indirection, potentially impacting performance in high-throughput Laravel APIs.
  • Testing Complexity:
    • Testing event-driven workflows (e.g., domain events, subscribers) in Laravel is already complex. Adding Symfony’s abstractions could complicate unit/integration tests without clear benefits.

Key Questions

  1. Why Symfony Boilerplate?
    • Does the team have existing Symfony expertise? Is there a strategic reason (e.g., migrating from Symfony) to adopt this pattern?
    • Could native Laravel packages (e.g., spatie/laravel-event-sourcing, laravel-ide-helper) achieve similar goals with less friction?
  2. DDD/CQRS Maturity
    • Is the Laravel project already structured around DDD/CQRS, or would this be a retrofit? Retrofitting can be risky.
  3. Long-Term Viability
    • Is the team willing to maintain a fork or build Laravel-specific adapters?
    • Are there alternative Laravel packages (e.g., fruitcake/laravel-cqrs) that offer similar functionality with better Laravel integration?
  4. Performance Requirements
    • Will the additional abstraction layers (e.g., buses, event dispatchers) impact scalability or latency?
  5. Team Buy-In
    • How comfortable is the team with Symfony’s patterns? Will this require additional training?

Integration Approach

Stack Fit

  • Laravel Core Compatibility:
    • The package does not natively integrate with Laravel’s stack. Key mismatches:
      • Messenger → Queues: Replace Symfony\Messenger with Illuminate\Queue (jobs) or Laravel Horizon for background processing.
      • EventDispatcher → Events: Use Illuminate\Events or Laravel Echo for event-driven workflows.
      • HTTP Kernel → Laravel Middleware: Replace HttpKernel subscribers with Laravel’s middleware or route filters.
    • Workaround: Use facades or interfaces to abstract Symfony components, allowing Laravel-native implementations behind them.
  • Database Layer:
    • Doctrine ORM → Eloquent: If using Eloquent, consider:
      • Abstract repositories (e.g., Illuminate\Contracts\Foundation\Application bindings).
      • Doctrine Bridge (doctrine/orm + illuminate/database) for hybrid setups.
  • Dependency Injection:
    • Laravel’s Service Container is PHP-DI compatible, but Symfony’s DependencyInjection is not natively supported. Use autowiring or manual bindings to resolve dependencies.

Migration Path

  1. Assessment Phase:
    • Audit the current Laravel architecture to identify DDD/CQRS pain points (e.g., command handling, event publishing).
    • Compare Symfony boilerplate features against native Laravel solutions (e.g., Illuminate\Bus, Laravel Nova Actions).
  2. Incremental Adoption:
    • Phase 1: Domain Events
      • Replace Symfony\Contracts\EventDispatcher with Illuminate\Events.
      • Use Laravel’s dispatch() for domain events.
    • Phase 2: Command/Query Buses
      • Replace Symfony\Component\Bus with:
        • Laravel’s Illuminate\Bus (for commands).
        • Custom query resolvers (if needed).
    • Phase 3: HTTP/Console Subscribers
      • Replace HttpKernel subscribers with:
        • Laravel middleware (for HTTP).
        • Artisan commands (for CLI).
  3. Hybrid Approach:
    • Use the Symfony boilerplate as a reference but implement Laravel-native equivalents.
    • Example:
      // Symfony-style (boilerplate)
      $bus->dispatch(new CreateUserCommand());
      
      // Laravel-native equivalent
      bus()->dispatch(new CreateUserCommand());
      
  4. Tooling Adaptation:
    • Replace Symfony’s make:command with Laravel’s make:command.
    • Use laravel-shift/blueprint for code generation if needed.

Compatibility

Symfony Boilerplate Feature Laravel Equivalent Compatibility Risk
Symfony\Component\Messenger Illuminate\Queue (Jobs) High (different APIs, middleware support)
Symfony\Component\EventDispatcher Illuminate\Events Low (similar API, but different event system)
Symfony\Component\Bus Illuminate\Bus Medium (different command handling)
Doctrine ORM Eloquent High (different query builders, repositories)
HttpKernel Subscribers Laravel Middleware Medium (different lifecycle hooks)
Console Subscribers Artisan Commands Low (direct replacement)

Sequencing

  1. Start with Non-Critical Paths:
    • Begin with domain events (low risk, high benefit).
    • Avoid replacing core request handling (e.g., middleware) until later.
  2. Leverage Existing Laravel Patterns:
    • Use Laravel’s built-in solutions where possible (e.g., Events, Bus).
    • Only adopt Symfony-style patterns for specific gaps (e.g., advanced CQRS).
  3. Pilot in a Feature Branch:
    • Test the integration in a non-production environment first.
    • Measure performance impact and developer productivity.
  4. Gradual Refactoring:
    • Replace one component at a time (e.g., events → commands → buses).
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