PHPackages                             dsentker/watcher - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Database &amp; ORM](/categories/database)
4. /
5. dsentker/watcher

ActiveLibrary[Database &amp; ORM](/categories/database)

dsentker/watcher
================

Allows to track changes on doctrine entities with an easy-to-use API.

0.3.0(2y ago)51.4kMITPHPPHP ^7.3 || ^8.0

Since Sep 8Pushed 2y ago1 watchersCompare

[ Source](https://github.com/dsentker/DoctrineWatcher)[ Packagist](https://packagist.org/packages/dsentker/watcher)[ RSS](/packages/dsentker-watcher/feed)WikiDiscussions master Synced 2d ago

READMEChangelog (10)Dependencies (3)Versions (18)Used By (0)

Watcher
=======

[](#watcher)

![GitHub release](https://camo.githubusercontent.com/d98e9735bcd493eaff23e7a66fb61aca8123abcd3d7f28b24828eb9aacd7d31b/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f72656c656173652f6473656e746b65722f446f637472696e65576174636865722e7376673f7374796c653d666c61742d737175617265)![Packagist](https://camo.githubusercontent.com/978f9ba11315ffe0e2530c43fe8044d0af71e781ee8736bbdee970f984b5cc4c/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6473656e746b65722f776174636865722e7376673f7374796c653d666c61742d737175617265)![Maintenance](https://camo.githubusercontent.com/221ef6b97ca1e8b269e9f526d605e3b8ecb0b208d45559321b6b3e0a6e3b42a1/68747470733a2f2f696d672e736869656c64732e696f2f6d61696e74656e616e63652f7965732f323031382e7376673f7374796c653d666c61742d737175617265)

**Allows to track changes on doctrine entities with an easy-to-use and highly customizable API.**

Documentation
-------------

[](#documentation)

[View Documentation](https://dsentker.github.io/WatcherDocumentation/)

Quick example
-------------

[](#quick-example)

You can use this library to track changes to Doctrine Entities. Use annotations to define the fields that you want to monitor. They determine where the changes are to be saved.

```
// User Entity class
/**
 * @Column(type="string")
 * @WatchedField // getRepository(User::class)->find(1);
$user->setUsername("A new username");
$em->persist($user);
$em->flush();

/** @var EntityLogRepository $logRepo */
$logRepo = $em->getRepository(EntityLog::class);

/** @var EntityLog[] $changes */
$changes = $logRepo->getLogsFromEntity($user);

$lastChange = $changes[0];
echo vsprintf("Last updated at (%s): Changed %s from '%s' to '%s'", [
    $lastChange->getChangedAt()->format('Y-m-d'),
    $lastChange->getFieldLabel(),
    $lastChange->getOldValue(),
    $lastChange->getNewValue(),
]); // Last updated at 2017-09-07: Changed Email Address from 'foo@example.com' to 'foo42@example.com'
```

Symfony4 services.yaml integration (example)
--------------------------------------------

[](#symfony4-servicesyaml-integration-example)

```
    watcher.db_handler:
        class:         App\Utils\AppWatcherHandler #your handler, e.g. Database Handler
        autowire:      true

    Watcher\EventListener\FlushListener:
        calls:
            -   method: pushUpdateHandler
                arguments:
                    - '@watcher.db_handler'
            -   method: setAnnotationReader
                arguments:
                    - '@annotations.reader'
        tags:
            - { name: doctrine.event_listener, event: onFlush }
    Watcher\EventListener\LoadListener:
        arguments:
            -  'App\Entity\EntityLog' # The entity which relates to EntityLogRepository
        tags:
            - { name: doctrine.event_listener, event: postLoad }
```

Known Limitations
-----------------

[](#known-limitations)

- This package is able to track changes on single fields and associations (collections), but depends on the concept of Doctrine, [which is limited to track changes on fields on the **owning side**](http://docs.doctrine-project.org/projects/doctrine-orm/en/latest/reference/unitofwork-associations.html). That means, that inverse side associations (`@OneToMany`) are NOT supported. `@ManyToMany` and `@ManyToOne` associations *are* supported.
- Also consider the overhead. If you've chosen the DatabaseHandler, each tracked entity change results in a single database request.

Testing
-------

[](#testing)

TBD (support is appreciated!)

Credits
-------

[](#credits)

- [Daniel Sentker](https://github.com/dsentker)

Submitting bugs and feature requests
------------------------------------

[](#submitting-bugs-and-feature-requests)

Bugs and feature request are tracked on GitHub.

ToDo
----

[](#todo)

- Use interfaces for everything
- Easy Symfony integration
- Write tests
- Optimize performance (group changes?)

External Libraries
------------------

[](#external-libraries)

This library depends on Doctrine (surprise!) and subpackages.

Copyright and license
---------------------

[](#copyright-and-license)

*Watcher* is licensed for use under the MIT License (MIT). Please see LICENSE for more information.

###  Health Score

32

—

LowBetter than 72% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity19

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity67

Established project with proven stability

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~138 days

Recently: every ~443 days

Total

17

Last Release

951d ago

PHP version history (2 changes)0.1.0PHP ^5.5 || ^7.0

0.3.0PHP ^7.3 || ^8.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/9309c19594a948d4f0314bbdb2d3cfd56c84027fbd0fac6497c3e7098046be63?d=identicon)[dsentker](/maintainers/dsentker)

---

Top Contributors

[![dsentker](https://avatars.githubusercontent.com/u/86192?v=4)](https://github.com/dsentker "dsentker (58 commits)")

---

Tags

change-detectorchange-trackerdoctrine-extensiondoctrine-ormdoctrine2entity-component

### Embed Badge

![Health badge](/badges/dsentker-watcher/health.svg)

```
[![Health](https://phpackages.com/badges/dsentker-watcher/health.svg)](https://phpackages.com/packages/dsentker-watcher)
```

###  Alternatives

[hautelook/alice-bundle

Symfony bundle to manage fixtures with Alice and Faker.

19519.4M34](/packages/hautelook-alice-bundle)[kimai/kimai

Kimai - Time Tracking

4.6k7.4k1](/packages/kimai-kimai)[sonata-project/entity-audit-bundle

Audit for Doctrine Entities

644989.8k1](/packages/sonata-project-entity-audit-bundle)[ec-cube/ec-cube

EC-CUBE EC open platform.

78527.0k1](/packages/ec-cube-ec-cube)[neos/flow

Flow Application Framework

862.0M451](/packages/neos-flow)[neos/flow-development-collection

Flow packages in a joined repository for pull requests.

144179.3k3](/packages/neos-flow-development-collection)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
