{"id":20776790,"url":"https://github.com/phpactor/amp-fswatch","last_synced_at":"2025-04-30T18:09:27.787Z","repository":{"id":54757722,"uuid":"249164358","full_name":"phpactor/amp-fswatch","owner":"phpactor","description":"Filesystem watcher supporting multiple strategies","archived":false,"fork":false,"pushed_at":"2024-02-28T12:50:52.000Z","size":134,"stargazers_count":11,"open_issues_count":2,"forks_count":2,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-30T18:09:20.680Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"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/phpactor.png","metadata":{"files":{"readme":"README.md","changelog":null,"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":"2020-03-22T10:58:35.000Z","updated_at":"2024-12-23T15:22:20.000Z","dependencies_parsed_at":"2024-02-28T13:50:37.169Z","dependency_job_id":"a654bf40-3b35-420b-b169-9e10e6ac233e","html_url":"https://github.com/phpactor/amp-fswatch","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/phpactor%2Famp-fswatch","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/phpactor%2Famp-fswatch/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/phpactor%2Famp-fswatch/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/phpactor%2Famp-fswatch/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/phpactor","download_url":"https://codeload.github.com/phpactor/amp-fswatch/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251758170,"owners_count":21638989,"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":[],"created_at":"2024-11-17T13:11:49.199Z","updated_at":"2025-04-30T18:09:27.757Z","avatar_url":"https://github.com/phpactor.png","language":"PHP","funding_links":[],"categories":["Filesystem"],"sub_categories":[],"readme":"Amp FS Watch\n============\n\n![CI](https://github.com/phpactor/amp-fswatch/workflows/CI/badge.svg)\n\nThis is an [Amp](https://amphp.org/) library for asynchronously monitor paths\non your file system changes using various stategues.\n\nIt's been created to trigger code indexing in\n[Phpactor](https://github.com/phpactor/phpactor).\n\n- Promise based API.\n- Capable of automatically selecting a supported watcher for the current\n  environment.\n- Provides realtime (e.g. ``inotify``) watchers in addition to polling ones.\n- Provides decorators for:\n  - Including / excluding patterns.\n  - Buffering notifications.\n- Unitifed configuration for all watchers.\n\nUsage\n-----\n\nSee `bin/watch` for an implementation, which looks _something_ like this:\n\n```php\nLoop::run(function () use () {\n\n    $logger = // create a PSR logger\n    $config = new WatcherConfig([$path]);\n    $watcher = new PatternMatchingWatcher(\n        new FallbackWatcher([\n            new BufferedWatcher(new InotifyWatcher($config, $logger), 10),\n            new FindWatcher($config, $logger),\n            new PhpPollWatcher($config, $logger),\n            new FsWatchWatcher($config, $logger)\n        ], $logger),\n        [ '/**/*.php' ],\n        []\n    );\n\n    $process = yield $watcher-\u003ewatch([$path]);\n\n    while (null !== $file = yield $process-\u003ewait()) {\n        fwrite(STDOUT, sprintf('[%s] %s (%s)'.\"\\n\", date('Y-m-d H:i:s.u'), $file-\u003epath(), $file-\u003etype()));\n    }\n});\n```\n### Watchman\n\n[Watchman](https://facebook.github.io/watchman/) needs to be installed and\nwill work on Linux, Mac and Windows.\n\n```php\nuse Phpactor\\AmpFsWatch\\Watcher\\Watchman\\WatchmanWatcher;\n\n$watcher = new WatchmanWatcher($config, $logger);\n```\n\n### Inotify\n\nUse the Linux `inotifywait` binary to monitor for changes.\n\n```php\nuse Phpactor\\AmpFsWatch\\Watcher\\Inotify\\InotifyWatcher;\n\n$watcher = new InotifyWatcher($config, $logger);\n// ...\n```\n\n### Fswatch\n\n**Unstable**: This watcher has not been extensively tested.\n\n[FsWatch](https://github.com/emcrisostomo/fswatch) is a cross-platform\n(Linux,Mac,Windows) file watching utility which will automatically use the\nplatforms native functionality when possible.\n\n```php\nuse Phpactor\\AmpFsWatch\\Watcher\\FsWatch\\FsWatchWatcher;\n\n$watcher = new FsWatchWatcher($config, $logger);\n// ...\n```\n\n### Find\n\nUse the `find` binary (Linux and Mac) to poll for file changes.\n\nPoll for changes every second:\n\n```php\nuse Phpactor\\AmpFsWatch\\Watcher\\Find\\FindWatcher;\n\n$watcher = new FindWatcher($config, $logger);\n// ...\n```\n\nNote that while this should work on GNU and BSD variants of `find` it may not\nwork on other variants due to being invoked with `-newerxy` switch, which is\nnot in the POSIX standard.\n\n### PHP Poll\n\nThis is the slowest and most resource intensive option but it should\nwork on all environments.\n\n```php\nuse Phpactor\\AmpFsWatch\\Watcher\\Find\\FindWatcher;\n\n$watcher = new PhpPollWatcher($config, $logger);\n// ...\n```\n\n### Fallback\n\nThe fallback watcher will automatically select the first supported watcher\non the current system:\n\n```php\nuse Phpactor\\AmpFsWatch\\Watcher\\Fallback\\FallbackWatcher;\n\n$watcher = new FallbackWatcher(\n    [\n        new InotifyWatcher($logger),\n        new FindWatcher(500, $logger)\n    ]\n    $logger\n);\n// ...\n```\n\nContributing\n------------\n\nThis package is open source and welcomes contributions! Feel free to open a\npull request on this repository.\n\nSupport\n-------\n\n- Create an issue on the main [Phpactor](https://github.com/phpactor/phpactor) repository.\n- Join the `#phpactor` channel on the Slack [Symfony Devs](https://symfony.com/slack-invite) channel.\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fphpactor%2Famp-fswatch","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fphpactor%2Famp-fswatch","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fphpactor%2Famp-fswatch/lists"}