{"id":15956370,"url":"https://github.com/dsentker/doctrinewatcher","last_synced_at":"2025-03-18T00:30:32.171Z","repository":{"id":56972828,"uuid":"102749516","full_name":"dsentker/DoctrineWatcher","owner":"dsentker","description":"Allows to track changes on doctrine entities with an easy-to-use and highly customizable API.","archived":false,"fork":false,"pushed_at":"2023-10-06T12:58:09.000Z","size":311,"stargazers_count":4,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-02-28T05:56:12.258Z","etag":null,"topics":["change-detector","change-tracker","doctrine-extension","doctrine-orm","doctrine2","entity-component"],"latest_commit_sha":null,"homepage":"https://dsentker.github.io/WatcherDocumentation/","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/dsentker.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-09-07T14:49:13.000Z","updated_at":"2023-08-15T08:22:55.000Z","dependencies_parsed_at":"2024-10-27T16:57:26.876Z","dependency_job_id":"85bbbf92-856f-4bee-8f1d-d4c80c15b625","html_url":"https://github.com/dsentker/DoctrineWatcher","commit_stats":{"total_commits":55,"total_committers":1,"mean_commits":55.0,"dds":0.0,"last_synced_commit":"1188cbb7f0a3f1fee95ae29d1c4f9ed733d5e678"},"previous_names":[],"tags_count":19,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dsentker%2FDoctrineWatcher","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dsentker%2FDoctrineWatcher/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dsentker%2FDoctrineWatcher/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dsentker%2FDoctrineWatcher/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dsentker","download_url":"https://codeload.github.com/dsentker/DoctrineWatcher/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243893566,"owners_count":20364914,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["change-detector","change-tracker","doctrine-extension","doctrine-orm","doctrine2","entity-component"],"created_at":"2024-10-07T13:32:06.505Z","updated_at":"2025-03-18T00:30:31.737Z","avatar_url":"https://github.com/dsentker.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Watcher\n\n [![GitHub release](https://img.shields.io/github/release/dsentker/DoctrineWatcher.svg?style=flat-square)]()\n [![Packagist](https://img.shields.io/packagist/v/dsentker/watcher.svg?style=flat-square)]()\n [![Maintenance](https://img.shields.io/maintenance/yes/2018.svg?style=flat-square)]()\n\n**Allows to track changes on doctrine entities with an easy-to-use and highly customizable API.**\n\n## Documentation\n[View Documentation](https://dsentker.github.io/WatcherDocumentation/)\n\n## Quick example\nYou 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.\n\n```php\n// User Entity class\n/**\n * @Column(type=\"string\")\n * @WatchedField // \u003c-- Watcher now tracks changes related to this field\n */\nprotected string $emailAddress;\n```\n\n***\n\n```php\n/**\n * @var $dbParams array\n * @var $config Configuration\n */\n$em = EntityManager::create($dbParams, $config, Watcher::createEventManager(new DatabaseHandler()));\nWatcher::registerAnnotations();\n\n\n/** @var $user User */\n$user = $em-\u003egetRepository(User::class)-\u003efind(1);\n$user-\u003esetUsername(\"A new username\");\n$em-\u003epersist($user);\n$em-\u003eflush();\n\n/** @var EntityLogRepository $logRepo */\n$logRepo = $em-\u003egetRepository(EntityLog::class);\n\n/** @var EntityLog[] $changes */\n$changes = $logRepo-\u003egetLogsFromEntity($user);\n\n$lastChange = $changes[0];\necho vsprintf(\"Last updated at (%s): Changed %s from '%s' to '%s'\", [\n    $lastChange-\u003egetChangedAt()-\u003eformat('Y-m-d'),\n    $lastChange-\u003egetFieldLabel(),\n    $lastChange-\u003egetOldValue(),\n    $lastChange-\u003egetNewValue(),\n]); // Last updated at 2017-09-07: Changed Email Address from 'foo@example.com' to 'foo42@example.com' \n```\n\n## Symfony4 services.yaml integration (example)\n```yaml\n\n    watcher.db_handler:\n        class:         App\\Utils\\AppWatcherHandler #your handler, e.g. Database Handler\n        autowire:      true\n\n    Watcher\\EventListener\\FlushListener:\n        calls:\n            -   method: pushUpdateHandler\n                arguments:\n                    - '@watcher.db_handler'\n            -   method: setAnnotationReader\n                arguments:\n                    - '@annotations.reader'\n        tags:\n            - { name: doctrine.event_listener, event: onFlush }\n    Watcher\\EventListener\\LoadListener:\n        arguments:\n            -  'App\\Entity\\EntityLog' # The entity which relates to EntityLogRepository\n        tags:\n            - { name: doctrine.event_listener, event: postLoad }\n\n```\n\n\u003ca name=\"limitations\"\u003e\u003c/a\u003e\n## Known Limitations\n* This package is able to track changes on single fields and associations (collections), but depends \non 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.\n* Also consider the overhead. If you've chosen the DatabaseHandler, each tracked entity change results in a single database request.\n\n\u003ca name=\"stuff\"\u003e\u003c/a\u003e\n## Testing\nTBD (support is appreciated!)\n \n## Credits\n* [Daniel Sentker](https://github.com/dsentker)\n \n## Submitting bugs and feature requests\nBugs and feature request are tracked on GitHub.\n \n## ToDo\n* Use interfaces for everything\n* Easy Symfony integration\n* Write tests\n* Optimize performance (group changes?)\n \n## External Libraries\nThis library depends on Doctrine (surprise!) and subpackages.\n \n## Copyright and license\n_Watcher_ is licensed for use under the MIT License (MIT). Please see LICENSE for more information.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdsentker%2Fdoctrinewatcher","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdsentker%2Fdoctrinewatcher","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdsentker%2Fdoctrinewatcher/lists"}