penguin/fswatch
最新稳定版本:v1.0.1
Composer 安装命令:
composer require penguin/fswatch
包简介
Library for monitoring file changes with fswatch
README 文档
README
This package provides a file watcher.
Installation
The current version only supports fswatch, so you'll have to install fswatch first.
# MacOS brew install fswatch # Linux wget https://github.com/emcrisostomo/fswatch/releases/download/{VERSION}/fswatch-{VERSION}.tar.gz tar -xzvf fswatch-{VERSION}.tar.gz cd fswatch-{VERSION} && ./configure && make && sudo make install && sudo ldconfig # Composer composer require penguin/fswatch
Usage
<?php use Penguin\Component\FsWatch\FsWatch; require __DIR__ . '/vendor/autoload.php'; (new FsWatch(__DIR__)) ->usePolling() // use poll_monitor (default is inotify in Linux, FSEvents in MacOS) // ignore files json, txt with regex ->ignore('.*\.json') ->ignore('.*\.txt') ->onChange(function (string $path) { echo "onChange {$path}"; });
Methods
onChange(callable $callback(string $path, Process $process))onAdd(callable $callback(string $path, Process $process))onUnlink(callable $callback(string $path, Process $process))onAddDir(callable $callback(string $path, Process $process))onError(callable $callback, Process $process)onAny(callable $callback(int $eventCode, string $path, Process $process)): Event will be executed when no other event is registeredusePolling(): Use poll monitor. The poll monitor, available on any platform, only relies on available CPU and memory to perform its task.oneEvent(): Exit fswatch after the first set of events is receivedmultiEvent(): Don't exit fswatch after events is receivedignore(string $regex): Exclude paths matching regexunWatch(string ...$paths)addWatch(string ...$paths)
统计信息
- 总下载量: 52
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 1
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2023-01-18