bentools/doctrine-watcher
Monitor Doctrine entity inserts and updates with a lightweight event subscriber. Watch specific classes and properties, get a changeset with old/new values or additions/removals, and run callbacks to react to changes (e.g., email or roles updates).
status changes to inactive") directly into entity operations without polluting business logic with technical concerns.Use This When:
User::email updates") rather than entity-wide hooks.save()) for side effects like logging, notifications, or external syncs.SELECT queries to compare old/new states).Look Elsewhere If:
prePersist/preUpdate.postPersist/postUpdate; use postRemove listeners separately.For Executives: "This package lets us automatically react to critical data changes—like role updates or email modifications—without manual checks. For example, we could auto-generate audit logs or trigger notifications when sensitive fields change, reducing compliance risks and operational overhead. It’s a lightweight, low-risk way to add event-driven logic to our Doctrine entities. The tradeoff? Minimal maintenance risk (last updated 2019) for a simple, MIT-licensed solution that avoids reinventing the wheel."
For Engineers:
*"Doctrine Watcher lets you subscribe to changes on specific entity properties (e.g., User::email) with callbacks for postPersist/postUpdate. It’s a drop-in event subscriber that avoids custom event listeners for property-level tracking. Useful for:
$watcher->watch(User::class, 'email', function ($changeset, $operation, User $user) {
if ($changeset->hasChanges()) {
// Trigger logic here
}
});
```*
**For Product Managers**:
*"This enables us to build features like:
- **Automated compliance logs** for regulated data (e.g., GDPR, HIPAA).
- **Real-time notifications** when critical fields change (e.g., user status updates).
- **Decoupled workflows** (e.g., 'if `Order::status` changes to `shipped`, update inventory').
No need for manual checks or polling—just register a watcher and let Doctrine handle the rest."*
How can I help you explore Laravel packages today?