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 Bridge Laravel Package

simple-bus/symfony-bridge

Symfony integration bridge for SimpleBus/MessageBus. Provides CommandBusBundle, EventBusBundle, and DoctrineORMBridgeBundle to wire command and event buses into your Symfony app, with docs and upgrade guide.

View on GitHub
Deep Wiki
Context7

Technical Evaluation

Architecture Fit

  • Event-Driven & CQRS Alignment: The package bridges SimpleBus (a lightweight, PHP-based messaging library) with Symfony, enabling command buses (for CQRS) and event buses (for event-driven architecture). This aligns well with Laravel applications seeking to adopt domain-driven design (DDD) or event sourcing patterns, especially if migrating from Symfony or integrating with legacy Symfony-based services.
  • Decoupling Benefits: SimpleBus promotes loose coupling between services via message buses, reducing direct dependencies between components. This is valuable in Laravel for microservices, background job decoupling, or real-time event handling (e.g., notifications, analytics).
  • Doctrine ORM Integration: The DoctrineORMBridgeBundle suggests potential for event persistence (e.g., storing events in a database for replayability), which could be adapted in Laravel via Doctrine DBAL or Eloquent events.

Integration Feasibility

  • Symfony-Specific: The package is Symfony-centric (uses Symfony bundles, dependency injection, and kernel events). Laravel’s service container and event system differ, requiring adapters (e.g., wrapping SimpleBus handlers in Laravel closures or using Laravel’s Bus facade as a facade over SimpleBus).
  • PHP Version Compatibility: SimpleBus supports PHP 7.4+, which aligns with Laravel’s 8.0+ requirements. No major version conflicts.
  • Middleware Support: SimpleBus supports message middleware (e.g., logging, validation), which can be mapped to Laravel’s middleware pipeline or queue middleware.

Technical Risk

  • Laravel-Symfony Abstraction Gap:
    • Symfony’s kernel events and bundles have no direct Laravel equivalent. Workarounds:
      • Use Laravel’s Event facade for event buses.
      • Replace CommandBusBundle with a custom facade or Laravel’s Bus (if using laravel-bus).
    • Risk: Boilerplate code to bridge Symfony-specific features (e.g., ContainerAware handlers).
  • Doctrine ORM Dependency:
    • Laravel primarily uses Eloquent. The DoctrineORMBridgeBundle would require Doctrine DBAL or a custom adapter for Laravel’s ORM.
    • Risk: Additional dependency overhead if not already using Doctrine.
  • Stale Maintenance:
    • Last release in 2021 with no dependents suggests low community adoption. Risk of unresolved bugs or incompatibility with newer Symfony/Laravel versions.
    • Mitigation: Fork or wrap the package in a Laravel-specific adapter layer.

Key Questions

  1. Why SimpleBus?
    • What problem does this solve that Laravel’s built-in queues, events, or jobs don’t address? (e.g., cross-service messaging, explicit command/event separation).
  2. Symfony Dependency Overhead
    • Are we willing to introduce Symfony components (e.g., ContainerInterface) for this bridge, or will we abstract them away?
  3. Alternatives
    • Would Laravel’s native queues, Laravel Bus, or Symfony Messenger (if using Symfony) be a better fit?
  4. Event Persistence
    • Do we need event storage/replay (via Doctrine), or is Laravel’s database logging sufficient?
  5. Testing & Debugging
    • How will we mock/test message handlers in a Laravel context (e.g., PHPUnit, Pest)?

Integration Approach

Stack Fit

  • Laravel Compatibility:
    • Command Bus: Replace Symfony’s CommandBusBundle with a custom facade wrapping SimpleBus’s CommandBus, injecting handlers via Laravel’s service container.
    • Event Bus: Use Laravel’s Event facade to dispatch events, with SimpleBus handling asynchronous processing (e.g., via queues).
    • Doctrine ORM: If needed, use Doctrine DBAL (via doctrine/dbal) instead of the full ORM to avoid Eloquent conflicts.
  • Middleware Mapping:
    • SimpleBus middleware (e.g., logging) can be mapped to Laravel’s queue middleware or event listeners.

Migration Path

  1. Phase 1: Proof of Concept
    • Implement a minimal command bus for a single use case (e.g., processing user registrations).
    • Replace Symfony’s ContainerAware handlers with Laravel’s container-aware closures.
  2. Phase 2: Event Bus Integration
    • Integrate SimpleBus’s event bus with Laravel’s Event system, using queued listeners for async processing.
  3. Phase 3: Doctrine (Optional)
    • If event persistence is needed, adapt DoctrineORMBridgeBundle to use DBAL or build a custom Laravel event store.
  4. Phase 4: Full Replacement
    • Gradually replace Laravel’s native queues/events with SimpleBus where appropriate (e.g., for cross-service communication).

Compatibility

  • Symfony-Specific Features:
    • Bundles: Not directly usable; must be replaced with Laravel service providers.
    • Kernel Events: Replace with Laravel’s events:dispatch or Bus::dispatch.
    • Configuration: Symfony’s config.yml → Laravel’s config/bus.php.
  • Laravel-Specific Features:
    • Queues: SimpleBus can wrap Laravel queues as a transport (e.g., RedisQueue, DatabaseQueue).
    • Service Container: Use Laravel’s app()->bind() to register SimpleBus components.

Sequencing

Step Task Dependencies Risks
1 Set up SimpleBus core (simple-bus/message-bus) PHP 8.0+ Version conflicts
2 Create Laravel facade for CommandBus Laravel 8.0+ Container binding issues
3 Register command handlers Existing Laravel services Handler compatibility
4 Integrate event bus with Laravel events Event facade Async event handling
5 (Optional) Adapt Doctrine ORM bridge Doctrine DBAL ORM complexity
6 Test with real commands/events Queue workers Performance bottlenecks

Operational Impact

Maintenance

  • Dependency Management:
    • SimpleBus is MIT-licensed but has no active maintenance. Monitor for security updates or fork if critical bugs arise.
    • Laravel’s ecosystem may evolve faster; ensure backward compatibility in custom wrappers.
  • Debugging:
    • Symfony’s bundle structure is unfamiliar to Laravel devs. Document error patterns (e.g., container binding failures).
    • Use Laravel’s Bus facade for simpler debugging than Symfony’s CommandBus.

Support

  • Community:
    • Limited to SimpleBus GitHub issues (not Laravel-specific). May need to build internal docs or contribute to the project.
  • Tooling:
    • IDE Support: Symfony bundles may cause autocomplete issues in PHPStorm/VSCode. Use PSR-4 autoloading to mitigate.
    • Artisan Commands: No built-in CLI tools; rely on Laravel’s artisan queue:work for bus processing.

Scaling

  • Performance:
    • SimpleBus is lightweight, but queue transport (e.g., Redis) will be the bottleneck. Benchmark against Laravel’s native queues.
    • Event bus: Async processing may introduce event ordering challenges (use queue jobs with unique IDs).
  • Horizontal Scaling:
    • SimpleBus supports multiple queue workers (like Laravel). Scale by increasing queue consumers.
    • Event sourcing: If using Doctrine for event storage, ensure database sharding is planned for high throughput.

Failure Modes

Failure Scenario Impact Mitigation
Queue Worker Crash Unprocessed commands/events Use Laravel’s queue retries and dead letter queues
Handler Exception Failed command/event Implement SimpleBus middleware for logging/retry
Database Locking (Doctrine) Event persistence failures Use optimistic locking or queue-based retries
Symfony-Laravel Abstraction Leak Fragile code Isolate SimpleBus in a separate service layer
Stale Package Security/bug vulnerabilities Monitor for forks or build a Laravel-specific fork

Ramp-Up

  • Learning Curve:
    • SimpleBus Concepts: Developers must understand commands vs. events, message middleware, and handler resolution.
    • Symfony-Laravel Mapping: Requires 1-2 days to document the bridge patterns.
  • Onboarding Resources:
    • Create a Laravel-specific README with:
      • Installation steps (Composer, service provider).
      • Example command/event handlers.
      • Debugging
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.
terminal42/code-quality-tools
codifyo/ts-generator-bundle
andydefer/laravel-cluster
testo/fiber
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