IGNORE_VCS_FILES
IGNORE_VCS_FILES = 1
Finder allows to build rules to find files and directories.
It is a thin wrapper around several specialized iterator classes.
All rules may be invoked several times.
All methods return the current Finder object to allow easy chaining:
$finder = Finder::create()->files()->name('*.php')->in(__DIR__);
depth(string|integer $level) : $this
Adds tests for the directory depth.
Usage:
$finder->depth('> 1') // the Finder will start matching at level 1.
$finder->depth('< 3') // the Finder will descend at most 3 levels of directories below the starting point.
string|integer | $level | The depth level expression |
date(string $date) : $this
Adds tests for file dates (last modified).
The date must be something that strtotime() is able to parse:
$finder->date('since yesterday');
$finder->date('until 2 days ago');
$finder->date('> now - 2 hours');
$finder->date('>= 2005-10-15');
string | $date | A date range string |
name(string $pattern) : $this
Adds rules that files must match.
You can use patterns (delimited with / sign), globs or simple strings.
$finder->name('*.php')
$finder->name('/\.php$/') // same as above
$finder->name('test.php')
string | $pattern | A pattern (a regexp, a glob, or a string) |
path(string $pattern) : $this
Adds rules that filenames must match.
You can use patterns (delimited with / sign) or simple strings.
$finder->path('some/special/dir')
$finder->path('/some\/special\/dir/') // same as above
Use only / as dirname separator.
string | $pattern | A pattern (a regexp or a string) |
notPath(string $pattern) : $this
Adds rules that filenames must not match.
You can use patterns (delimited with / sign) or simple strings.
$finder->notPath('some/special/dir')
$finder->notPath('/some\/special\/dir/') // same as above
Use only / as dirname separator.
string | $pattern | A pattern (a regexp or a string) |
sortByChangedTime() : $this
Sorts files and directories by the last inode changed time.
This is the time that the inode information was last modified (permissions, owner, group or other metadata).
On Windows, since inode is not available, changed time is actually the file creation time.
This can be slow as all the matching files and directories must be retrieved for comparison.
getIterator() : \Iterator|array<mixed,\Symfony\Component\Finder\SplFileInfo>
Returns an Iterator for the current Finder configuration.
This method implements the IteratorAggregate interface.
if the in() method has not been called
An iterator
append(\Symfony\Component\Finder\iterable $iterator) : $this
Appends an existing set of files/directories to the finder.
The set can be another Finder, an Iterator, an IteratorAggregate, or even a plain array.
\Symfony\Component\Finder\iterable | $iterator |
when the given argument is not iterable