Download the PHP package brash/phpwatcher without Composer
On this page you can find all versions of the php package brash/phpwatcher. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package phpwatcher
PHP Watcher
This work is based on e-dant's 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
Here's how you can start watching a directory and get notified of any changes:
Integrated Binary
Besides directly call the API, it is useful to simply use composer to watch for a file and the current working directory:
This will watch for changes in all current working directory, i.e, root project where the vendor folder is located.
Change Types
Change types can be listened through the following API:
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
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 Speed
To change the Watcher's speed, simply use:
Versioning
This package follows the semver semantic versioning specification.
All versions of phpwatcher with dependencies
minicli/minicli Version ^4.2
nunomaduro/termwind Version ^2.0
php Version ^8.3
revolt/event-loop Version ^1.0@dev
symfony/process Version ^7.0