PHPackages                             brash/phpwatcher - 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. brash/phpwatcher

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

brash/phpwatcher
================

A package to watch filesystem events

v1.0.2(1y ago)050MITPHPPHP ^8.3CI passing

Since Dec 26Pushed 1y agoCompare

[ Source](https://github.com/BrashPHP/phpwatcher)[ Packagist](https://packagist.org/packages/brash/phpwatcher)[ RSS](/packages/brash-phpwatcher/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (3)Dependencies (10)Versions (4)Used By (0)

PHP Watcher
===========

[](#php-watcher)

This work is based on [e-dant's watcher](https://github.com/e-dant/watcher). It will watch any changes in the given filesystem path using PHP. Under the hood it uses Watcher, A filesystem event watcher that is simple, fast and efficient. Since it is only necessary to use the watcher binary to listen to any changes, this was the chosen method to keep tracking of any events that happen within the filesystem, as others usually have more overhead and consume more resources.

Usage
-----

[](#usage)

Here's how you can start watching a directory and get notified of any changes:

```
use Brash\PhpWatcher\Bootstrapper;
use Brash\PhpWatcher\Watcher;
use Brash\PhpWatcher\WatchEvent;
use Revolt\EventLoop;

require_once "./vendor/autoload.php";

$watcher = new Watcher();
$watcher->watchPath(__DIR__)
    ->onAnyChange(function (WatchEvent $event): void {
        // Do anything to event
    });

$watcher->start();

// Not REALLY necessary, since when this process ends all children process must end too.
EventLoop::onSignal(SIGINT, fn () => $watcher->stop());

EventLoop::run();
```

### Integrated Binary

[](#integrated-binary)

Besides directly call the API, it is useful to simply use composer to watch for a file and the current working directory:

```
./vendor/bin/watch watch path="your_path"
```

This will watch for changes in all current working directory, i.e, root project where the vendor folder is located.

### Change Types

[](#change-types)

Change types can be listened through the following API:

```
function Watcher::on(
    EffectEventWatchEnum[] $effects,
    PathTypeEnum[] $types,
    callable $callable
): Watcher;
```

Where the effect type can be one of:

```
case RENAME = "rename";
case MODIFY = "modify";
case CREATE = "create";
case DESTROY = "destroy";
case OWNER = "owner";
case OTHER = "other";

```

Path type can be one of:

```
case DIR = 'dir';
case FILE = 'file';
case HARD_LINK = 'hard_link';
case SYM_LINK = 'sym_link';
case WATCHER = 'watcher';

```

And a callable should be provided in the signature `function(WatchEvent $event): void`.

### Stopping the watcher gracefully

[](#stopping-the-watcher-gracefully)

By default, the watcher will continue indefinitely when started. To gracefully stop the watcher, you can call shouldContinue and pass it a closure. If the closure returns a falsy value, the watcher will stop. The given closure will be executed every 0.5 second.

```
$watcher->shouldContinue(fn () => false);
```

### Watcher Speed

[](#watcher-speed)

To change the Watcher's speed, simply use:

```
$watcher->setIntervalTime(1); // in seconds
```

Versioning
----------

[](#versioning)

This package follows the semver semantic versioning specification.

###  Health Score

29

—

LowBetter than 59% of packages

Maintenance41

Moderate activity, may be stable

Popularity8

Limited adoption so far

Community2

Small or concentrated contributor base

Maturity55

Maturing project, gaining track record

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 ~9 days

Total

3

Last Release

490d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/2754bf7a9174f2abafce9571a9d87dc2e705c284aedbe227cab3e3f85c9bfb61?d=identicon)[Gabriel Berthier](/maintainers/Gabriel%20Berthier)

---

Tags

fibersfilesystemphpwatcher

###  Code Quality

TestsPest

Code StyleLaravel Pint

### Embed Badge

![Health badge](/badges/brash-phpwatcher/health.svg)

```
[![Health](https://phpackages.com/badges/brash-phpwatcher/health.svg)](https://phpackages.com/packages/brash-phpwatcher)
```

###  Alternatives

[spatie/laravel-health

Monitor the health of a Laravel application

86910.0M83](/packages/spatie-laravel-health)[illuminate/console

The Illuminate Console package.

12944.1M5.1k](/packages/illuminate-console)[spatie/file-system-watcher

Watch changes in the file system using PHP

2502.1M17](/packages/spatie-file-system-watcher)

PHPackages © 2026

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