- How do I integrate SimpleBusBridge with an existing Laravel project?
- First, install the package via Composer (`composer require bengor-file/simple-bus-bridge`) and ensure you have the required dependencies: `simplebus/simple-bus` and `bengor-file/file`. Then, create a custom Laravel service provider to bind SimpleBus components to Laravel’s container and map SimpleBus messages to Laravel events or vice versa. The README suggests using PHPSpec for testing, but you may need to adapt it to Laravel’s PHPUnit/Pest ecosystem.
- Does this package support Laravel 10+ or modern PHP versions?
- The package requires PHP 5.5+, which technically works with Laravel 5.5+, but it was last updated in 2018. There’s no official support for Laravel 10+ or PHP 8.x, so you’d need to manually test compatibility or fork the project. The abandoned maintenance status raises concerns about long-term viability, especially with PHP 5.5 being EOL since 2016.
- Can I use SimpleBusBridge for background jobs instead of Laravel Queues?
- Yes, but with trade-offs. SimpleBusBridge enables file-based command/event dispatching, which could replace Laravel Queues for offline-capable workflows (e.g., batch processing). However, Laravel’s queues (Redis, database) are optimized for performance and scalability, while file-based persistence may introduce latency or failure risks (e.g., disk issues). Benchmark both approaches for your use case.
- What’s the difference between this and Laravel’s native event system?
- SimpleBusBridge integrates Matthias Noback’s SimpleBus, a lightweight command bus, with the File library for persistence. Laravel’s event system is pub/sub-based and tightly integrated with its container, while SimpleBus focuses on command dispatching and event sourcing. This package is useful if you need file-based state management or are migrating from a SimpleBus-based legacy system to Laravel.
- Will this work with Laravel’s service container and IoC?
- Not out of the box. You’ll need to manually bind SimpleBus components (e.g., command buses, handlers) to Laravel’s container in a service provider. The package doesn’t include Laravel-specific integrations, so you’ll handle dependency injection and lifecycle management yourself. Consider using Laravel’s `bind()` or `extend()` methods for seamless integration.
- Are there alternatives to SimpleBusBridge for Laravel?
- Yes. For event-driven architectures, consider Laravel’s built-in events or Symfony Messenger (via `symfony/messenger`). For file-based workflows, Laravel Filesystem Events or custom queue listeners may suffice. If you need SimpleBus specifically, alternatives like `php-event-bus` or `reactphp/event-loop` might offer modern PHP 8.x support without the File library dependency.
- How do I test SimpleBusBridge in a Laravel project?
- The package uses PHPSpec, but you can adapt its tests to Laravel’s PHPUnit/Pest. Mock SimpleBus components (e.g., command buses, handlers) and verify interactions with the File library. For Laravel-specific tests, use `Mockery` or `Laravel’s testing helpers` to simulate event dispatching or queue jobs. Ensure your tests cover edge cases like file system failures or message serialization.
- Does this package support transactional file operations?
- No, SimpleBusBridge doesn’t include transactional guarantees for file operations. The File library handles persistence, but you’d need to implement custom logic (e.g., atomic writes, rollback mechanisms) if transactions are critical. Laravel’s database transactions won’t apply here, so consider using filesystem locks or external tools like `flock()` for concurrency control.
- Can I use this for real-time event processing in Laravel?
- Unlikely. SimpleBusBridge is designed for file-based persistence, which introduces latency compared to real-time systems like Laravel Echo or Pusher. For real-time needs, pair Laravel’s broadcasting with a dedicated event bus (e.g., RabbitMQ via `php-amqplib`) or use Laravel’s native events with WebSockets. File-based processing is better suited for batch jobs or offline workflows.
- What are the failure modes of file-based SimpleBus dispatching?
- Key risks include disk failures (corrupting stored messages), message loss if not persisted atomically, and performance bottlenecks with high I/O. Unlike Laravel Queues (which use Redis/database), file-based systems lack built-in retries or dead-letter queues. Mitigate these by implementing backup strategies, monitoring file system health, and adding manual retry logic for failed commands.