PHPackages                             lyfter/amp-fswatch - 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. [File &amp; Storage](/categories/file-storage)
4. /
5. lyfter/amp-fswatch

ActiveLibrary[File &amp; Storage](/categories/file-storage)

lyfter/amp-fswatch
==================

Async Filesystem Watcher for Amphp

1.1.0(4w ago)03.5k↓43%MITPHPPHP ^8.0

Since Jan 28Pushed 4w agoCompare

[ Source](https://github.com/lyfter/amp-fswatch)[ Packagist](https://packagist.org/packages/lyfter/amp-fswatch)[ RSS](/packages/lyfter-amp-fswatch/feed)WikiDiscussions master Synced today

READMEChangelog (2)Dependencies (28)Versions (3)Used By (0)

Amp FS Watch
============

[](#amp-fs-watch)

[![CI](https://github.com/phpactor/amp-fswatch/workflows/CI/badge.svg)](https://github.com/phpactor/amp-fswatch/workflows/CI/badge.svg)

This is an [Amp](https://amphp.org/) library for asynchronously monitor paths on your file system changes using various stategues.

It's been created to trigger code indexing in [Phpactor](https://github.com/phpactor/phpactor).

- Promise based API.
- Capable of automatically selecting a supported watcher for the current environment.
- Provides realtime (e.g. `inotify`) watchers in addition to polling ones.
- Provides decorators for:
    - Including / excluding patterns.
    - Buffering notifications.
- Unitifed configuration for all watchers.

Usage
-----

[](#usage)

See `bin/watch` for an implementation, which looks *something* like this:

```
Loop::run(function () use () {

    $logger = // create a PSR logger
    $config = new WatcherConfig([$path]);
    $watcher = new PatternMatchingWatcher(
        new FallbackWatcher([
            new BufferedWatcher(new InotifyWatcher($config, $logger), 10),
            new FindWatcher($config, $logger),
            new PhpPollWatcher($config, $logger),
            new FsWatchWatcher($config, $logger)
        ], $logger),
        [ '/**/*.php' ],
        []
    );

    $process = yield $watcher->watch([$path]);

    while (null !== $file = yield $process->wait()) {
        fwrite(STDOUT, sprintf('[%s] %s (%s)'."\n", date('Y-m-d H:i:s.u'), $file->path(), $file->type()));
    }
});
```

### Watchman

[](#watchman)

[Watchman](https://facebook.github.io/watchman/) needs to be installed and will work on Linux, Mac and Windows.

```
use Phpactor\AmpFsWatch\Watcher\Watchman\WatchmanWatcher;

$watcher = new WatchmanWatcher($config, $logger);
```

### Inotify

[](#inotify)

Use the Linux `inotifywait` binary to monitor for changes.

```
use Phpactor\AmpFsWatch\Watcher\Inotify\InotifyWatcher;

$watcher = new InotifyWatcher($config, $logger);
// ...
```

### Fswatch

[](#fswatch)

**Unstable**: This watcher has not been extensively tested.

[FsWatch](https://github.com/emcrisostomo/fswatch) is a cross-platform (Linux,Mac,Windows) file watching utility which will automatically use the platforms native functionality when possible.

```
use Phpactor\AmpFsWatch\Watcher\FsWatch\FsWatchWatcher;

$watcher = new FsWatchWatcher($config, $logger);
// ...
```

### Find

[](#find)

Use the `find` binary (Linux and Mac) to poll for file changes.

Poll for changes every second:

```
use Phpactor\AmpFsWatch\Watcher\Find\FindWatcher;

$watcher = new FindWatcher($config, $logger);
// ...
```

Note that while this should work on GNU and BSD variants of `find` it may not work on other variants due to being invoked with `-newerxy` switch, which is not in the POSIX standard.

### PHP Poll

[](#php-poll)

This is the slowest and most resource intensive option but it should work on all environments.

```
use Phpactor\AmpFsWatch\Watcher\Find\FindWatcher;

$watcher = new PhpPollWatcher($config, $logger);
// ...
```

### Fallback

[](#fallback)

The fallback watcher will automatically select the first supported watcher on the current system:

```
use Phpactor\AmpFsWatch\Watcher\Fallback\FallbackWatcher;

$watcher = new FallbackWatcher(
    [
        new InotifyWatcher($logger),
        new FindWatcher(500, $logger)
    ]
    $logger
);
// ...
```

Contributing
------------

[](#contributing)

This package is open source and welcomes contributions! Feel free to open a pull request on this repository.

Support
-------

[](#support)

- Create an issue on the main [Phpactor](https://github.com/phpactor/phpactor) repository.
- Join the `#phpactor` channel on the Slack [Symfony Devs](https://symfony.com/slack-invite) channel.

###  Health Score

41

—

FairBetter than 87% of packages

Maintenance85

Actively maintained with recent releases

Popularity22

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity39

Early-stage or recently created project

 Bus Factor1

Top contributor holds 96.9% 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 ~126 days

Total

2

Last Release

29d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/18738854?v=4)[Lyfter](/maintainers/lyfter)[@lyfter](https://github.com/lyfter)

---

Top Contributors

[![dantleech](https://avatars.githubusercontent.com/u/530801?v=4)](https://github.com/dantleech "dantleech (125 commits)")[![michaelw85](https://avatars.githubusercontent.com/u/3629094?v=4)](https://github.com/michaelw85 "michaelw85 (3 commits)")[![MatmaRex](https://avatars.githubusercontent.com/u/160413?v=4)](https://github.com/MatmaRex "MatmaRex (1 commits)")

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StylePHP CS Fixer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/lyfter-amp-fswatch/health.svg)

```
[![Health](https://phpackages.com/badges/lyfter-amp-fswatch/health.svg)](https://phpackages.com/packages/lyfter-amp-fswatch)
```

###  Alternatives

[aws/aws-sdk-php

AWS SDK for PHP - Use Amazon Web Services in your PHP project

6.3k543.5M2.6k](/packages/aws-aws-sdk-php)[tempest/framework

The PHP framework that gets out of your way.

2.2k34.4k15](/packages/tempest-framework)[phpbench/phpbench

PHP Benchmarking Framework

2.0k14.6M847](/packages/phpbench-phpbench)[phpactor/phpactor

PHP refactoring and intellisense tool for text editors

1.9k17.1k1](/packages/phpactor-phpactor)[drupal/core

Drupal is an open source content management platform powering millions of websites and applications.

21866.0M1.7k](/packages/drupal-core)[flow-php/flow

PHP ETL - Extract Transform Load - Data processing framework

85036.3k](/packages/flow-php-flow)

PHPackages © 2026

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