event-engine/php-postgres-document-store
PostgreSQL-backed document store for Event Engine (PHP). Store, update, and query JSON documents efficiently using Postgres features like JSONB and indexes. Designed for read models/projections with a simple API and solid performance.
event_id, aggregate_id, timestamp).Event interface, EventStore contract). Non-compliant event structures may need adapters.->> for path queries) can be slower than native relational queries. Benchmark with expected event volume (e.g., 10K events/sec).SELECT ... FOR UPDATE SKIP LOCKED.version field) or pessimistic locking? How does the package handle conflicts?Laravel Integration Layers:
DB facade or a custom repository. Example:
DB::table('event_store')->insert([
'aggregate_id' => $aggregateId,
'event_data' => json_encode($event),
'metadata' => ['timestamp' => now()],
]);
EventStore interface compatible with Laravel’s event system (e.g., dispatch()).$eventStore = app(EventEnginePostgresStore::class);
$eventStore->append($aggregateId, $event);
PostgreSQL Configuration:
CREATE EXTENSION IF NOT EXISTS "uuid-ossp"; CREATE EXTENSION IF NOT EXISTS "pg_trgm";.postgresql.conf for high concurrency:
max_connections = 200
shared_buffers = 4GB
work_mem = 16MB
Order) with the document store.GET events FOR aggregate X).CREATE INDEX idx_event_store_aggregate_id ON event_store(aggregate_id);
CREATE INDEX idx_event_store_type_timestamp ON event_store(event_type, occurred_on);
aggregate_id if sharding is needed.json_encode/decode performance quirks.jsonb_path_query).EventEngine\Event interface. Use a data transfer object (DTO) layer to normalize event structures.Schema::table('event_store', function (Blueprint $table) {
$table->jsonb('metadata')->nullable()->after('event_data');
});
composer.json to avoid surprises:
"event-engine/php-postgres-document-store": "1.2.*"
jsonb_set repairs).pg_stat_activity to identify blocking queries.pg_stat_statements and analyze with EXPLAIN ANALYZE.jsonb_typeof() and jsonb_path_exists().\Log::debug('Appended event', ['data' => $event, 'query' => $query->toSql()]);
pgsql-general mailing list).How can I help you explore Laravel packages today?