- Can I use this package with Laravel’s Eloquent ORM for event queries?
- No, this package doesn’t integrate directly with Eloquent. You’ll need to use raw PostgreSQL queries via Laravel’s DB facade or build a custom repository layer. For frequent event queries, consider extending Eloquent to support JSONB fields manually.
- What Laravel versions does this package support?
- The package targets PHP 8.0+ and is designed for Laravel 9/10. Check the GitHub repo for exact version constraints, as it depends on Event Engine’s abstractions, which may have their own Laravel version requirements.
- How do I handle event sourcing transactions with this store?
- Use PostgreSQL transactions via Laravel’s DB facade to ensure atomicity between event appends and projections. Wrap your operations in `DB::transaction()` to maintain consistency. Example: `DB::transaction(fn() => $store->append($event));`
- Does this package support optimistic concurrency control?
- No, the package doesn’t enforce optimistic concurrency out of the box. You’ll need to implement it manually, such as adding a `version` field to your events and checking it before updates. PostgreSQL’s `FOR UPDATE SKIP LOCKED` can help with pessimistic locking.
- Can I query nested JSON fields in stored events?
- Yes, the package leverages PostgreSQL’s JSONB operators (e.g., `->`, `->>`, `@>`) for nested queries. Example: `SELECT * FROM events WHERE event_data->'user'->>'id' = '123'`. Index these paths for performance.
- How does this compare to using MongoDB for event storage?
- This package avoids vendor lock-in to MongoDB while retaining JSON flexibility. PostgreSQL offers ACID transactions, SQL querying, and built-in full-text search—ideal for read models. However, MongoDB may be simpler for unstructured data or horizontal scaling.
- What’s the performance impact of storing events as JSONB?
- JSONB queries can be slower than native relational columns, especially for deep nesting. Benchmark with your event volume (e.g., 10K events/sec) and index frequently queried paths. For high-throughput systems, consider denormalizing critical fields.
- How do I integrate this with Laravel’s event system (e.g., `dispatch()`)?
- Wrap the package in a Laravel service provider to expose an `EventStore` interface. Then, bind it to Laravel’s container and use dependency injection. Example: `$eventStore = app(EventEnginePostgresStore::class); $eventStore->append($event);`
- Are there tools for debugging or inspecting stored events?
- No built-in Laravel tooling exists. Use PostgreSQL’s `pgAdmin` or CLI tools (`psql`) to inspect tables. For Laravel-specific debugging, create custom Artisan commands or admin panels to query the `event_store` table.
- How do I handle schema evolution for dynamic event attributes?
- PostgreSQL’s JSONB schema is backward-compatible, so adding new fields won’t break reads. For migrations, use Laravel’s schema builder to alter tables if needed. Forward-compatibility risks arise if your code assumes fixed event structures—validate dynamically.