ralfhortt/php-watch-files
Composer 安装命令:
composer require ralfhortt/php-watch-files
包简介
Watch file or folder and execute code when something is changes inside
README 文档
README
Watch file or folder and execute code when something is changed inside
Demo
You can run the following command to see how the script works
php index.php FILE_OR_FOLDER_PATH
Basic usage
$watcher = new \ralfhortt\fswatcher\Watcher('FILE_OR_FOLDER_PATH_TO_WATCH', function ($event) { // Do whatever you want when file or folder is changed. if ($event->isAddition()){ // File was added and file path will be $event->file } else if ($event->isModification()){ // File was modified and file path will be $event->file } }); $watcher->watch();
Advanced Usage
$watcher = new \ralfhortt\fswatcher\Watcher('FILE_OR_FOLDER_PATH_TO_WATCH', 'callback', [ 'watchInterval' => 5, 'cacheChanges' => true ]);
Options
| Option | Default value | Description |
|---|---|---|
| watchInterval | 1 | How often the file changes should be checked |
| cacheChanges | true | Gather file modifications in single check and trigger event once |
Credits
- The code is written by Zura Sekhniashvili zurasekhniashvili@gmail.com
- I've repacked it as a composer package
统计信息
- 总下载量: 25
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 2
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2022-04-16