PHPackages                             innmind/file-watch - 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. innmind/file-watch

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

innmind/file-watch
==================

Library to execute code when a file changes

6.0.1(2mo ago)152.5k↓27%1[1 issues](https://github.com/Innmind/FileWatch/issues)3MITPHPPHP ~8.4CI passing

Since Jan 19Pushed 2mo ago1 watchersCompare

[ Source](https://github.com/Innmind/FileWatch)[ Packagist](https://packagist.org/packages/innmind/file-watch)[ Docs](http://github.com/Innmind/FileWatch)[ RSS](/packages/innmind-file-watch/feed)WikiDiscussions develop Synced 1mo ago

READMEChangelog (7)Dependencies (7)Versions (16)Used By (3)

FileWatch
=========

[](#filewatch)

[![CI](https://github.com/Innmind/FileWatch/actions/workflows/ci.yml/badge.svg?branch=master)](https://github.com/Innmind/FileWatch/actions/workflows/ci.yml)[![codecov](https://camo.githubusercontent.com/ee9902d997fb59f22e3cee3b538fa9c76bf52127eb711d6ce34bd6d49f7c35f0/68747470733a2f2f636f6465636f762e696f2f67682f696e6e6d696e642f66696c6577617463682f6272616e63682f646576656c6f702f67726170682f62616467652e737667)](https://codecov.io/gh/innmind/filewatch)[![Type Coverage](https://camo.githubusercontent.com/9a547e66aaf79385015a29ae115821f5577703b93bd90d21a110f03061f8778a/68747470733a2f2f73686570686572642e6465762f6769746875622f696e6e6d696e642f66696c6577617463682f636f7665726167652e737667)](https://shepherd.dev/github/innmind/filewatch)

Small tool to execute code every time a file (or folder) is modified.

Installation
------------

[](#installation)

```
composer require innmind/file-watch
```

Usage
-----

[](#usage)

```
use Innmind\FileWatch\Factory;
use Innmind\Server\Control\ServerFactory;
use Innmind\TimeWarp\Halt;
use Innmind\TimeContinuum\Clock;
use Innmind\IO\IO;
use Innmind\Url\Path;
use Innmind\Immutable\Either;

$watch = Factory::build(
    ServerFactory::build(
        Clock::live(),
        IO::fromAmbientAuthority(),
        Halt::new(),
    )->processes(),
    Halt::new(),
);

$count = $watch(Path::of('/to/some/file/or/folder'))(0, function(int $count, Continuation $continuation): Continuation {
    // this function is called every time the file is modified
    ++$count;

    if ($count === 42) {
        // This will stop watching the folder for changes and return the count
        return $continuation->stop($count);
    }

    // This will instruct to continue watching for changes and the value will be
    // passed to this callable the next time it's called
    return $continuation->continue($count);
})->match(
    static fn(int $count) => $count, // always 42 as it's the stopping value
    static fn(\Throwable $e) => throw $e,
);
```

Warning

The function may be called multiple times for a single change due to the way `tail` and `stat` works.

###  Health Score

54

—

FairBetter than 97% of packages

Maintenance63

Regular maintenance activity

Popularity33

Limited adoption so far

Community15

Small or concentrated contributor base

Maturity86

Battle-tested with a long release history

 Bus Factor1

Top contributor holds 99.3% 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 ~215 days

Recently: every ~208 days

Total

13

Last Release

85d ago

Major Versions

1.1.1 → 2.0.02020-01-19

2.2.0 → 3.0.02022-02-27

3.2.0 → 4.0.02024-03-10

4.0.0 → 5.0.02025-05-08

5.0.0 → 6.0.02026-02-07

PHP version history (6 changes)1.0.0PHP ~7.2

2.0.0PHP ~7.4

2.1.0PHP ~7.4|~8.0

3.0.0PHP ~8.1

3.2.0PHP ~8.2

6.0.0PHP ~8.4

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/851425?v=4)[Baptiste Langlade](/maintainers/Baptouuuu)[@Baptouuuu](https://github.com/Baptouuuu)

---

Top Contributors

[![Baptouuuu](https://avatars.githubusercontent.com/u/851425?v=4)](https://github.com/Baptouuuu "Baptouuuu (137 commits)")[![peter279k](https://avatars.githubusercontent.com/u/9021747?v=4)](https://github.com/peter279k "peter279k (1 commits)")

---

Tags

filewatch

### Embed Badge

![Health badge](/badges/innmind-file-watch/health.svg)

```
[![Health](https://phpackages.com/badges/innmind-file-watch/health.svg)](https://phpackages.com/packages/innmind-file-watch)
```

###  Alternatives

[league/flysystem

File storage abstraction for PHP

13.6k639.1M2.2k](/packages/league-flysystem)[league/flysystem-aws-s3-v3

AWS S3 filesystem adapter for Flysystem.

1.6k263.6M790](/packages/league-flysystem-aws-s3-v3)[knplabs/gaufrette

PHP library that provides a filesystem abstraction layer

2.5k39.8M123](/packages/knplabs-gaufrette)[league/flysystem-local

Local filesystem adapter for Flysystem.

225231.8M39](/packages/league-flysystem-local)[sonata-project/media-bundle

Symfony SonataMediaBundle

4625.5M71](/packages/sonata-project-media-bundle)[adlawson/vfs

Virtual file system

300433.0k21](/packages/adlawson-vfs)

PHPackages © 2026

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