yosymfony/resource-watcher
Composer 安装命令:
composer require yosymfony/resource-watcher
包简介
A simple resource watcher using Symfony Finder
README 文档
README
A simple resource watcher for getting changes of your filesystem.
Installation
Use Composer to install this package:
composer require yosymfony/resource-watcher
How to use?
This package uses Symfony Finder to set the criteria to discover file changes.
use Symfony\Component\Finder\Finder; use Yosymfony\ResourceWatcher\Crc32ContentHash; use Yosymfony\ResourceWatcher\ResourceWatcher; use Yosymfony\ResourceWatcher\ResourceCachePhpFile; $finder = new Finder(); $finder->files() ->name('*.md') ->in(__DIR__); $hashContent = new Crc32ContentHash(); $resourceCache = new ResourceCachePhpFile('/path-cache-file.php'); $watcher = new ResourceWatcher($resourceCache, $finder, $hashContent); $watcher->initialize(); // delete a file $result = $watcher->findChanges(); $result->getDeletedResources() // array of deleted filenames. e.g: "/home/yosymfony/README.md"
Finding changes
Every time the method findChanges() of the class ResourceWatcher is invoked,
it returns an object type ResourceWatcherResult with information about all the
changes producced in the filesystem. The ResourceWatcherResult class has the following methods:
getNewFiles(): Returns an array with the paths of the new resources.getDeteledFiles(): Returns an array with the paths of deleted resources.getUpdatedFiles(): Returns an array with the paths of the updated resources.hasChanges(): Are they changes in your resources?.
Hashing alternatives
Two hashing classes are included in the package:
Yosymfony\ResourceWatcher\Crc32ContentHash, which hashes the content of the fileYosymfony\ResourceWatcher\Crc32MetaDataHash, which hashes the filename and its last modified timestamp
Rebuild cache
To rebuild the resource cache uses rebuild() method of the class ResourceWatcher.
Relative paths with the resource cache
Using relative paths with the resource cache is possible thanks to the
ResourceWatcher's method enableRelativePathWithCache:
$watcher = new ResourceWatcher($resourceCache, $finder, $hashContent); $watcher->enableRelativePathWithCache()
The ResourceWatcherResult object will has relative paths.
Unit tests
You can run the unit tests with the following command:
$ composer test
yosymfony/resource-watcher 适用场景与选型建议
yosymfony/resource-watcher 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 8.85M 次下载、GitHub Stars 达 69, 最近一次更新时间为 2014 年 08 月 28 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「symfony」 「finder」 「resources」 「watcher」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 yosymfony/resource-watcher 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 yosymfony/resource-watcher 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 yosymfony/resource-watcher 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Resource group sub-menus for Laravel Nova.
PHP Library to get the apple-touch-icons and favicon from a website.
The bundle for easy using json-rpc api on your project
Payment resources library used by the official CCV Payment Services plugins
Filament package to prevent the update of outdated records.
Bundle Symfony DaplosBundle
统计信息
- 总下载量: 8.85M
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 71
- 点击次数: 38
- 依赖项目数: 28
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2014-08-28