定制 lav45/watcher 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

lav45/watcher

最新稳定版本:1.0.1

Composer 安装命令:

composer require lav45/watcher

包简介

File change watcher

README 文档

README

Watcher listens and calls event handlers that happen to your files.

Usage example

use Lav45\Watcher\Event;
use Lav45\Watcher\Listener;
use Lav45\Watcher\Watcher;

$watcher = (new Watcher(new Listener()))
    ->on(IN_CREATE | IN_MOVED_TO, static function(Event $event) {
        echo 'Create ' . $event->path . "\n";
    })
    ->on(IN_DELETE | IN_MOVED_FROM, static function(Event $event) {
        echo 'Delete ' . $event->path . "\n";
    })
    ->on(IN_MODIFY, static function(Event $event) {
        echo 'Update ' . $event->path . "\n";
    })
    ->withFilter(fn(Event $event): bool => \str_ends_with($event->path, '.json'))
    ->watchDirs([__DIR__]);

while (true) {
    $watcher->read();
    sleep(1);
}

Testing

docker run --rm -it -v $(pwd):/app composer install --ignore-platform-req=ext-inotify
docker run --rm -it -v $(pwd):/app composer test

统计信息

  • 总下载量: 176
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2024-08-27