{"id":16461534,"url":"https://github.com/yosymfony/resource-watcher","last_synced_at":"2025-04-05T15:09:50.952Z","repository":{"id":20170193,"uuid":"23440980","full_name":"yosymfony/resource-watcher","owner":"yosymfony","description":"A resource watcher for getting changes of your filesystem using Symfony Finder","archived":false,"fork":false,"pushed_at":"2023-12-29T15:13:44.000Z","size":51,"stargazers_count":69,"open_issues_count":5,"forks_count":19,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-03-29T14:11:53.749Z","etag":null,"topics":["file","php","symfony","watcher"],"latest_commit_sha":null,"homepage":"","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/yosymfony.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"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":"2014-08-28T19:53:16.000Z","updated_at":"2025-01-26T18:49:35.000Z","dependencies_parsed_at":"2024-06-18T12:22:25.081Z","dependency_job_id":"934ffcc4-f29b-4275-9442-77d54baaf231","html_url":"https://github.com/yosymfony/resource-watcher","commit_stats":{"total_commits":45,"total_committers":7,"mean_commits":6.428571428571429,"dds":0.2222222222222222,"last_synced_commit":"fda1c5333360d89b537677fe3d856b0480dea81c"},"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yosymfony%2Fresource-watcher","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yosymfony%2Fresource-watcher/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yosymfony%2Fresource-watcher/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yosymfony%2Fresource-watcher/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/yosymfony","download_url":"https://codeload.github.com/yosymfony/resource-watcher/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247353749,"owners_count":20925329,"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":["file","php","symfony","watcher"],"created_at":"2024-10-11T11:08:31.969Z","updated_at":"2025-04-05T15:09:50.935Z","avatar_url":"https://github.com/yosymfony.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"A simple resource watcher for getting changes of your filesystem.\n\n[![Build Status](https://travis-ci.org/yosymfony/resource-watcher.png?branch=master)](https://travis-ci.org/yosymfony/resource-watcher)\n[![Latest Stable Version](https://poser.pugx.org/yosymfony/resource-watcher/v/stable.png)](https://packagist.org/packages/yosymfony/resource-watcher)\n\n## Installation\n\nUse [Composer](http://getcomposer.org/) to install this package:\n\n```bash\ncomposer require yosymfony/resource-watcher\n```\n\n## How to use?\n\nThis package uses [Symfony Finder](http://symfony.com/doc/current/components/finder.html)\nto set the criteria to discover file changes.\n\n```php\nuse Symfony\\Component\\Finder\\Finder;\nuse Yosymfony\\ResourceWatcher\\Crc32ContentHash;\nuse Yosymfony\\ResourceWatcher\\ResourceWatcher;\nuse Yosymfony\\ResourceWatcher\\ResourceCachePhpFile;\n\n$finder = new Finder();\n$finder-\u003efiles()\n    -\u003ename('*.md')\n    -\u003ein(__DIR__);\n\n$hashContent = new Crc32ContentHash();\n$resourceCache = new ResourceCachePhpFile('/path-cache-file.php');\n$watcher = new ResourceWatcher($resourceCache, $finder, $hashContent);\n$watcher-\u003einitialize();\n\n// delete a file\n\n$result = $watcher-\u003efindChanges();\n\n$result-\u003egetDeletedResources() // array of deleted filenames. e.g: \"/home/yosymfony/README.md\"\n```\n\n### Finding changes\n\nEvery time the method `findChanges()` of the class `ResourceWatcher` is invoked,\nit returns an object type `ResourceWatcherResult` with information about all the\nchanges producced in the filesystem. The `ResourceWatcherResult` class has the following methods:\n\n* `getNewFiles()`: Returns an array with the paths of the new resources.\n* `getDeteledFiles()`: Returns an array with the paths of deleted resources.\n* `getUpdatedFiles()`: Returns an array with the paths of the updated resources.\n* `hasChanges()`: Are they changes in your resources?.\n\n### Hashing alternatives\nTwo hashing classes are included in the package: \n* `Yosymfony\\ResourceWatcher\\Crc32ContentHash`, which hashes the content of the file\n* `Yosymfony\\ResourceWatcher\\Crc32MetaDataHash`, which hashes the filename and its last modified timestamp\n\n### Rebuild cache\n\nTo rebuild the resource cache uses `rebuild()` method of the class `ResourceWatcher`.\n\n### Relative paths with the resource cache\n\nUsing relative paths with the resource cache is possible thanks to the\nResourceWatcher's method `enableRelativePathWithCache`:\n\n```php\n$watcher = new ResourceWatcher($resourceCache, $finder, $hashContent);\n$watcher-\u003eenableRelativePathWithCache()\n```\n\nThe `ResourceWatcherResult` object will has relative paths.\n\n## Unit tests\n\nYou can run the unit tests with the following command:\n\n```bash\n$ composer test\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyosymfony%2Fresource-watcher","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fyosymfony%2Fresource-watcher","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyosymfony%2Fresource-watcher/lists"}