atournayre/entities-events-bundle
EventDispatcher and Doctrine ORM events, aligning well with modern Symfony architectures (e.g., DDD, CQRS, or workflow-driven systems). It abstracts event dispatching for CRUD operations, reducing boilerplate for common use cases like notifications, auditing, or side-effect triggers.HasEventsInterface and EventsTrait enforce a declarative approach, tying events directly to entities. This fits systems where domain logic is tightly coupled to entity lifecycle (e.g., e-commerce order processing, user activity tracking).DependencyInjection, Console, and Doctrine. The use of #[AsEventListener] (Symfony 6.3+) modernizes listener registration.prePersist, preUpdate, preRemove, etc., reducing manual event handling in repositories/services.OrderPaidEvent) alongside standard Doctrine events, enabling granular control.^2.16), limiting use to Symfony projects with Doctrine. Non-Doctrine projects (e.g., Eloquent) would need alternative implementations.EventCollection) may introduce memory overhead for high-throughput systems. No benchmarks or optimizations (e.g., batching) are documented.EventsTrait enforces a specific entity structure, which could conflict with existing codebases using custom entity traits or interfaces.dispatcher->dispatch() calls (e.g., automatic CRUD event mapping, listener generation)?EventDispatcher profiler integration)?EventDispatcher) into custom code?EventDispatcher + custom listenersapi-platform/core (for API-driven projects)symfony/lock for concurrent event handling.EventDispatcher, Console).User, Order).HasEventsInterface + EventsTrait pattern.php bin/console atournayre:entities-events:generate-listeners.prePersist/preUpdate logic with bundle-generated events.EventDispatcher) into a custom package.^2.16. Projects using older/new versions may need adjustments.#[AsEventListener], so older Symfony 6.x may need manual listener registration.UuidTrait). May require composition over inheritance.generate-listeners to scaffold initial listeners.HasEventsInterface and EventsTrait to target entities.OrderShippedEvent).OrderShippedListener).postPersist).generate-listeners) automates boilerplate.EventCollection to every entity, increasing memory usage.EventsTrait makes it hard to switch to alternative event systems.EventCollection per entity may scale poorly for high-cardinality systems (e.g., 1M+ entities). Consider lazy event dispatching or batching.preUpdate). Ensure transactions and locks are optimized.| Scenario | Impact | Mitigation Strategy |
|---|---|---|
| Package Abandonment | No updates, security risks | Fork the repo or extract logic into custom code. |
| Event Dispatch Failures | Silent failures if unhandled | Add error handlers for critical events. |
| Memory Leaks | High entity counts crash app | Monitor memory; implement event batching. |
| Doctrine Event Conflicts | Overrides existing listeners | Test thoroughly; use stopPropagation sparingly. |
| PHP 8.3+ Incompatibility | Breaks on upgrade | Pin PHP version or patch the bundle. |
HasEventsInterface to 1–2 entities.EventDispatcher docs and Doctrine events.EventDispatcher) into a custom package for stability.How can I help you explore Laravel packages today?