Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Doctrine Watcher Laravel Package

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).

View on GitHub
Deep Wiki
Context7

Product Decisions This Supports

  • Audit Logging & Compliance: Enables automatic tracking of sensitive property changes (e.g., user roles, financial data) without manual intervention, reducing compliance risks and audit effort.
  • Event-Driven Architecture: Facilitates decoupled, reactive systems by triggering custom logic (e.g., notifications, syncs, or workflows) in response to entity changes, improving modularity and maintainability.
  • Custom Business Rules: Allows embedding domain-specific logic (e.g., "revoke access if status changes to inactive") directly into entity operations without polluting business logic with technical concerns.
  • Build vs. Buy: Justifies adopting this lightweight package over building custom event listeners or integrating heavier frameworks (e.g., Symfony’s full event system) for property-level change detection.
  • Roadmap Validation: Demonstrates demand for fine-grained entity change monitoring, potentially prioritizing future investments in a more robust event system or audit infrastructure.

When to Consider This Package

  • Use This When:

    • You need property-specific change detection (e.g., "alert when User::email updates") rather than entity-wide hooks.
    • Your stack uses Doctrine ORM and PHP 7.1+, with no plans to migrate away.
    • You require post-operation triggers (e.g., after save()) for side effects like logging, notifications, or external syncs.
    • Your use case tolerates minimal maintenance risk (last release: 2019) for a simple, MIT-licensed solution.
    • You want to avoid polling or manual checks for entity changes (e.g., no SELECT queries to compare old/new states).
  • Look Elsewhere If:

    • You need pre-operation hooks (e.g., validation before saving) → Use Doctrine Lifecycle Callbacks or Symfony’s prePersist/preUpdate.
    • Your entities are high-frequency (e.g., bulk inserts) → The package adds event listener overhead; consider batch processing optimizations.
    • You require active maintenance (e.g., PHP 8+ support, bug fixes) → Evaluate forking or alternatives like Doctrine Extensions.
    • You need delete event support → This package only watches postPersist/postUpdate; use postRemove listeners separately.
    • You’re using non-Doctrine ORMs (e.g., Eloquent, Propel) → This is a hard blocker.

How to Pitch It (Stakeholders)

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:

  • Audit trails: Log who changed what and when.
  • Side effects: Sync external systems or invalidate caches.
  • Validation: Post-save checks (e.g., 'did the email actually change?'). Configurable to ignore no-changes cases or trigger on inserts. Downside: Unmaintained but stable for PHP 7.1+. Example:
$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."*
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
daikazu/eloquent-salesforce-objects
unseen-codes/chat
romalytar/yammi-jobs-monitoring-laravel
kisame76/filament-db-table-state
nqxcode/laravel-lucene-search
dpfx/laravel-livewire-wizards
workos/workos-php-laravel
sofa/laravel-global-scope
nawasara/auth-primitives
adhocrat-io/arkhe-main
make-dev/orca-harpoon
itsemon245/lamet
baks-dev/dashboard
amoifr/pickle-panther-bundle
make-dev/orca
dmstr/symfony-system-resources-bundle
dmstr/symfony-job-queue-bundle
dmstr/openapi-json-schema-bundle
dmstr/keycloak-security-bundle
dmstr/doctrine-audit-log-bundle