How ylikscherbak/elasticsearch-audit-bundle works
Elasticsearch Audit Bundle is a Symfony audit-history bundle: it captures Doctrine changes and explicitly submitted domain events, completes and optionally coalesces records, redacts them, then writes synchronously or through Messenger to Elasticsearch. Its read API builds filtered, paginated queries over that history; operational commands check and manage indices. The README documents the main record lifecycle and the Doctrine/Messenger options. Several internals are represented at subsystem level because their source was not excerpted.
Main entry points: AuditWriter.php Manual audit calls · Transport Transport selection · Messenger Messenger workers · GatewayInterface.php Elasticsearch gateway
Components 20
Record capture
- Doctrine auditing
src/Doctrine - Manual audit calls
src/Writer/AuditWriter.php
Record processing
- Audit record
src/Model/AuditRecord.php - Actor resolution
src/Actor - Record enrichment
src/Contract - Coalescing frames
src/Coalescing/FrameBuffer.php - Privacy redaction
src/Privacy/ChangeRedactor.php - Created event
src/Event/RecordCreatedEvent.php
Storage and delivery
- Transport selection
src/Transport - Messenger workers
src/Transport/Messenger - Transactional outbox
src/Transport/Outbox - Elasticsearch gateway
src/Elasticsearch/GatewayInterface.php - Elasticsearch
History access
- Audit reader
src/Reader/AuditReader.php - Query construction
src/Reader/QueryBuilder.php - Filterable query
src/Model/AuditQuery.php
Configuration and operations
- Index commands
src/Command - Bundle configuration
src/DependencyInjection/ElasticsearchAuditExtension.php
Other components
- Application
- Symfony Messenger
Connections 24
- Application → Manual audit calls: records events
- Doctrine auditing → Manual audit calls: submits changes
- Manual audit calls → Audit record: builds records
src/Writer/AuditWriter.php - Manual audit calls → Actor resolution: resolves actor
src/Writer/AuditWriter.php - Manual audit calls → Record enrichment: runs enrichers
src/Writer/AuditWriter.php - Manual audit calls → Coalescing frames: buffers records
src/Writer/AuditWriter.php - Coalescing frames → Audit record: merges changes
src/Coalescing/FrameBuffer.php - Manual audit calls → Privacy redaction: redacts records
src/Writer/AuditWriter.php - Manual audit calls → Created event: dispatches event
src/Writer/AuditWriter.php - Manual audit calls → Transport selection: releases records
src/Writer/AuditWriter.php - Transport selection → Elasticsearch gateway: writes directly
src/Transport/Messenger/IndexAuditRecordsHandler.php - Transport selection → Messenger workers: queues records
src/Transport/Messenger/IndexAuditRecordsHandler.php - Symfony Messenger → Messenger workers: invokes handlers
src/Transport/Messenger/IndexAuditRecordsHandler.php - Messenger workers → Elasticsearch gateway: writes batches
src/Transport/Messenger/IndexAuditRecordsHandler.php - Elasticsearch gateway → Elasticsearch: stores and searches
- Transport selection → Transactional outbox: may use outbox
- Application → Audit reader: requests history
- Audit reader → Query construction: builds searches
- Audit reader → Elasticsearch gateway: searches history
- Query construction → Filterable query: reads filters
src/Reader/QueryBuilder.php - Application → Index commands: runs index checks
- Bundle configuration → Manual audit calls: configures services
src/DependencyInjection/ElasticsearchAuditExtension.php - Bundle configuration → Messenger workers: configures handlers
src/DependencyInjection/ElasticsearchAuditExtension.php - Bundle configuration → Doctrine auditing: enables auditing
src/DependencyInjection/ElasticsearchAuditExtension.php