PHPackages                             phpactor/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. phpactor/amp-fswatch

ActiveLibrary

phpactor/amp-fswatch
====================

Async Filesystem Watcher for Amphp

0.3.0(2y ago)11458.9k↓43.8%4[3 PRs](https://github.com/phpactor/amp-fswatch/pulls)3MITPHPPHP ^8.0

Since Mar 28Pushed 2y ago1 watchersCompare

[ Source](https://github.com/phpactor/amp-fswatch)[ Packagist](https://packagist.org/packages/phpactor/amp-fswatch)[ RSS](/packages/phpactor-amp-fswatch/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (14)Versions (8)Used By (3)

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

37

—

LowBetter than 83% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity44

Moderate usage in the ecosystem

Community16

Small or concentrated contributor base

Maturity56

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 99.2% 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 ~401 days

Total

4

Last Release

1010d ago

PHP version history (3 changes)0.1.0PHP ^7.2

0.2.0PHP ^7.3 || ^8.0

0.3.0PHP ^8.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/24ec7d5d6b7ea54007be5d7b4f43800381cc1e22929f7d2276fba30e497fdfa6?d=identicon)[dantleech](/maintainers/dantleech)

---

Top Contributors

[![dantleech](https://avatars.githubusercontent.com/u/530801?v=4)](https://github.com/dantleech "dantleech (125 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/phpactor-amp-fswatch/health.svg)

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

###  Alternatives

[phpbench/phpbench

PHP Benchmarking Framework

2.0k13.0M627](/packages/phpbench-phpbench)[vimeo/psalm

A static analysis tool for finding errors in PHP applications

5.8k77.5M6.7k](/packages/vimeo-psalm)[sylius/sylius

E-Commerce platform for PHP, based on Symfony framework.

8.4k5.6M651](/packages/sylius-sylius)[shopware/platform

The Shopware e-commerce core

3.3k1.5M3](/packages/shopware-platform)[danog/madelineproto

Async PHP client API for the telegram MTProto protocol.

3.4k855.0k18](/packages/danog-madelineproto)[phpro/soap-client

A general purpose SoapClient library

8885.6M46](/packages/phpro-soap-client)

PHPackages © 2026

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