antikirra/find
最新稳定版本:1.0.0
Composer 安装命令:
composer require antikirra/find
包简介
README 文档
README
Install
composer require antikirra/find
Basic usage
<?php use Antikirra\Find\Find; require __DIR__ . '/vendor/autoload.php'; $finder = Find::in('/path/to/dir'); $iterator = $finder->find(function (SplFileInfo $fileInfo) { return $fileInfo->getSize() === 0 ? $fileInfo : null; }); foreach ($iterator as $realPath => $fileInfo) { // do stuff }
Demo
<?php use Antikirra\Find\Find; require __DIR__ . '/vendor/autoload.php'; $finder = Find::in('/Users/antikirra/PhpstormProjects') ->filesOnly() //->withExtensions(['txt', 'php']) //->directoriesOnly() //->withSoftLimit(10) //->withHardLimit(10000) ; $iterator = $finder->find(function (SplFileInfo $fileInfo) { // files modified within the last hour return time() - $fileInfo->getMTime() < 3600 ? $fileInfo : null; }); foreach ($iterator as $realPath => $fileInfo) { echo $realPath . ' - ' . date('Y-m-d H:i:s', $fileInfo->getMTime()) . PHP_EOL; } // /Users/antikirra/PhpstormProjects/find/composer.lock - 2023-05-24 21:21:46 // /Users/antikirra/PhpstormProjects/find/README.md - 2023-05-24 21:31:57 // /Users/antikirra/PhpstormProjects/find/Find.php - 2023-05-24 21:21:14 // /Users/antikirra/PhpstormProjects/find/composer.json - 2023-05-24 21:21:14 // ...
统计信息
- 总下载量: 116
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2023-05-24