- Can I use php-messaging to replace Laravel’s built-in event system for distributed systems?
- Yes, but with a bridge. Laravel’s native events are synchronous, while php-messaging is designed for async/distributed workflows. You’d need a custom event listener to forward Laravel events to the messaging bus or vice versa. For full integration, consider using it alongside Laravel’s queue system for async processing.
- Does php-messaging work with Laravel’s queue system (e.g., Redis, database drivers)?
- Not natively, but it’s transport-agnostic. You can configure it to use Laravel’s queue drivers (like Redis or database) by implementing a custom transport adapter. Check the package’s docs for supported brokers like Kafka or RabbitMQ, and adapt if needed for Laravel’s ecosystem.
- How do I install and bootstrap php-messaging in a Laravel project?
- Install via Composer: `composer require event-engine/php-messaging`. The package doesn’t include a Laravel service provider by default, so you’ll need to manually register transports, middleware, or listeners in your `AppServiceProvider`. Follow the README for transport setup (e.g., Kafka, RabbitMQ).
- What Laravel versions does php-messaging support, and are there breaking changes?
- The package targets PHP 8.0+ and is framework-agnostic, but Laravel compatibility depends on your setup. For Laravel 9/10, ensure your PHP version matches (8.0+). No Laravel-specific breaking changes are documented, but test with your version. Check the GitHub issues for version-specific notes.
- How does php-messaging handle event serialization (e.g., JSON, Protobuf)?
- It supports structured serialization out of the box (e.g., JSON, MessagePack) for distributed messaging. Laravel’s native events use arrays/objects, so you’ll need to serialize/deserialize payloads manually or build a wrapper. For Protobuf, integrate a library like `google/protobuf` and configure the package’s serializer.
- Can I use php-messaging for real-time updates (e.g., WebSocket pushes triggered by events)?
- Absolutely. The package’s event bus can dispatch messages to WebSocket services via Laravel Echo or custom listeners. Subscribe to events in your messaging system, then broadcast them to WebSocket clients. Pair it with Laravel’s `Broadcast` facade for seamless real-time updates.
- What are the failure modes, and how does php-messaging handle retries or dead-letter queues?
- The package supports middleware for error handling, including retries and dead-letter queues. Configure a `DeadLetterQueue` transport or use middleware to log failed events. For Laravel integration, extend this with queue failure callbacks or custom middleware to align with Laravel’s retry logic.
- Are there alternatives to php-messaging for Laravel event-driven architectures?
- Yes. For Laravel-native solutions, consider `spatie/laravel-queueable-events` for async events or `laravel-horizon` for queue monitoring. For distributed messaging, evaluate `symfony/messenger` (with Laravel bridges) or `pusher/pusher-php-server` for real-time. Choose based on your need for event sourcing or broker support.
- How do I test php-messaging in Laravel, especially for distributed scenarios?
- Use Laravel’s mocking tools (Mockery) for unit tests and in-memory brokers (e.g., `php-amqplib` with a test queue) for integration tests. For event sourcing, mock the event store or use Laravel’s database transactions. The package may lack Laravel-specific testing utilities, so build custom test doubles for transports.
- Does php-messaging support event sourcing or CQRS patterns in Laravel?
- It’s designed for event sourcing/CQRS but requires additional setup in Laravel. Use it to dispatch domain events to an event store (e.g., Doctrine Event Store or a custom table). For CQRS, pair it with Laravel’s query objects and a read model. The package handles the messaging layer; you’ll need to implement the sourcing logic.