huang-yi/swoole-watcher 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

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

huang-yi/swoole-watcher

最新稳定版本:v1.0.1

Composer 安装命令:

composer require huang-yi/swoole-watcher

包简介

Swoole file watcher.

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 (building from Source)
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

A user who wishes to build fswatch should get a release tarball

Then, make sure you have swoole extension installed in PHP.

pecl install swoole

Finally, you may install the Swoole Watcher via Composer:

composer require huang-yi/swoole-watcher

Usage

Create your watcher script like this:

<?php

require __DIR__ . '/vendor/autoload.php';

use HuangYi\Watcher\Commands\Fswatch;
use HuangYi\Watcher\Watcher;

$command = new Fswatch('/watched/path');

$command->setOptions([
    '--recursive' => true,
    '--filter-from' => '/path/to/filter-rules-file',
]);

$watcher = new Watcher($command);

// Registers a callback for an event.
$watcher->on(Fswatch::CREATED, function ($path) {
    // do something...
});

// or registers a default callback for any event.
$watcher->onChange(function ($events) {
    // do something...
});

$watcher->start();

License

Swoole Watcher is open-sourced software licensed under the MIT license.

统计信息

  • 总下载量: 14.86k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 14
  • 点击次数: 0
  • 依赖项目数: 2
  • 推荐数: 1

GitHub 信息

  • Stars: 14
  • Watchers: 2
  • Forks: 4
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2017-11-20