thapp / fileitr
Bunch of fileiterators
Installs: 11
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 3
Forks: 0
Open Issues: 0
Type:package
Requires
- php: ^5.6 || ^7.0
Requires (Dev)
- phpunit/phpunit: ^5.3
This package is not auto-updated.
Last update: 2024-12-19 02:00:17 UTC
README
Requirements
php >= 5.6
Installation
> composer require thapp/fileitr
Usage
PatternIterator
PatternIterator
is used to recursively iterate over directories and files using
a regular expression as filter.
<?php use Thapp\Fileitr\PatternIterator; // iterates over a maximum directory depth of 2, searching for files with a '.php' suffix $itr = new PatternIterator($path, '/\.(php)$/', 2, -1, $flags); // iterates over a maximum directory depth of 1, and limits overall files to 3. $itr = new PatternIterator($path, '/\.(php)$/', 1, 3, $flags);
RecursiveDirectoryIterator
The RecursiveDirectoryIterator
extends \RecursiveDirectoryIterator
.
Key differences:
- ability to limit overall file count.
- will ouput a custom FileInfo Object including relative path, and relative pathname
- only accepts
CURRENT_AS_FILEINFO
, notCURRENT_AS_SELF
norCURRENT_AS_PATHNAME