当前位置: 首页>>代码示例>>PHP>>正文


PHP Filesystem::find方法代码示例

本文整理汇总了PHP中League\Flysystem\Filesystem::find方法的典型用法代码示例。如果您正苦于以下问题:PHP Filesystem::find方法的具体用法?PHP Filesystem::find怎么用?PHP Filesystem::find使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在League\Flysystem\Filesystem的用法示例。


在下文中一共展示了Filesystem::find方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: Filesystem

use Flyfinder\Finder;
use Flyfinder\Path;
use Flyfinder\Specification\IsHidden;
use Flyfinder\Specification\HasExtension;
use Flyfinder\Specification\InPath;
/*
 * First create a new Filesystem and add the FlySystem plugin
 * In this example we are using a filesystem with the memory adapter
 */
$filesystem = new Filesystem(new Adapter());
$filesystem->addPlugin(new Finder());
// Create some demo files
$filesystem->write('test.txt', 'test');
$filesystem->write('.hiddendir/.test.txt', 'test');
$filesystem->write('.hiddendir/found.txt', 'test');
$filesystem->write('.hiddendir/normaldir/example.txt', 'test');
/*
 * In order to tell FlyFinder what to find, you need to give it a specification
 * In this example the specification will be satisfied by *.txt files
 * within the .hidden directory and its subdirectories that are not hidden
 */
$isHidden = new IsHidden();
$hasExtension = new HasExtension(['txt']);
$inPath = new InPath(new Path('.hiddendir'));
$specification = $inPath->andSpecification($hasExtension)->andSpecification($isHidden->notSpecification());
//FlyFinder will yield a generator object with the files that are found
$generator = $filesystem->find($specification);
$result = [];
foreach ($generator as $value) {
    $result[] = $value;
}
开发者ID:phpdocumentor,项目名称:flyfinder,代码行数:31,代码来源:02-find-on-multiple-criteria.php


注:本文中的League\Flysystem\Filesystem::find方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。