Product Decisions This Supports
- Audit Logging & Compliance: Enables granular tracking of entity changes (e.g., user updates, financial records) for regulatory compliance (GDPR, SOX) or audit trails without manual instrumentation.
- Change Detection for Workflows: Powers dynamic workflows (e.g., "notify admin if
status changes to published") by leveraging hasChanged() checks.
- Build vs. Buy: Avoids reinventing change-tracking logic for Doctrine entities, reducing dev time and technical debt.
- Nested Object Support: Resolves edge cases where Doctrine’s default change tracking fails for complex object graphs (e.g., embedded objects, relationships).
- Data Validation: Validates changesets pre-save (e.g., "reject if
price drops below cost") using ChangeSet methods like hadPreviousValue().
- Roadmap: Foundation for future features like:
- Change Diff Visualization: Integrate with frontend to show "before/after" changes.
- Automated Rollback: Trigger rollbacks on invalid changesets (e.g., via Doctrine listeners).
- Event-Driven Actions: Extend to emit events (e.g.,
OnPropertyChanged) for real-time processing.
When to Consider This Package
Adopt if:
- Your app uses Doctrine ORM and needs fine-grained change tracking beyond basic
UnitOfWork methods.
- You require nested object change detection (e.g., tracking changes in embedded
Address objects within User).
- You’re building audit logs, workflows, or validation tied to entity state changes.
- Your team prefers MIT-licensed, lightweight solutions over proprietary tools.
Look elsewhere if:
- You’re using non-Doctrine ORMs (e.g., Eloquent, Propel).
- Your change-tracking needs are simple (e.g., only need
isDirty()).
- You need real-time sync (e.g., WebSocket updates)—this is server-side only.
- Your stack is non-PHP (e.g., Node.js, Python).
- You require GUI tools for change visualization (consider standalone diff libraries).
How to Pitch It (Stakeholders)
For Executives:
"This package lets us automate change tracking for critical data (e.g., user profiles, orders) with minimal code, reducing audit risks and enabling smarter workflows. For example, we could auto-notify support when a customer’s status changes to inactive—saving 10+ dev hours and improving compliance. It’s a lightweight, MIT-licensed tool that integrates seamlessly with our existing Doctrine setup, with zero vendor lock-in."
For Engineers:
*"The EntityTracker gives us programmatic access to Doctrine’s change data without hacking UnitOfWork. Key perks:
- Nested object support: Finally track changes in
User->Address->City without manual workarounds.
- Flexible queries: Check
hasChanged($entity, 'field') or validate changesets with hadPreviousValue().
- Extensible: Hook into Doctrine listeners or events for custom logic.
Downside: Low stars (but MIT, active maintenance, and zero dependents = low risk). Let’s prototype it for the audit-logging feature—if it works, we can expand it to workflows."*
For Developers:
*"Replace this:
if ($entity->name !== $originalName) { ... } // Manual diffing
With this:
if ($tracker->hasChanged($entity, 'name')) {
$changeSet = $tracker->getChangeSet($entity, 'name');
// $changeSet->from/to for easy validation
}
Bonus: The [TrackChanges] attribute fixes Doctrine’s blind spot for nested objects. Zero config—just inject EntityTracker."*