• Home
  • History
  • Annotate
Name Date Size #Lines LOC

..18-Apr-2016-

Adapter/H09-Jul-2015-1,018534

Comparator/H09-Jul-2015-235110

Exception/H09-Jul-2015-15749

Expression/H09-Jul-2015-688326

Iterator/H09-Jul-2015-1,024455

Shell/H09-Jul-2015-393164

CHANGELOG.mdH A D09-Jul-20151.1 KiB3527

Finder.phpH A D09-Jul-201521.5 KiB841329

Glob.phpH A D09-Jul-20153.1 KiB10456

LICENSEH A D09-Jul-20151 KiB2016

README.mdH A D09-Jul-20151.4 KiB5440

SplFileInfo.phpH A D09-Jul-20151.8 KiB7832

README.md

1Finder Component
2================
3
4Finder finds files and directories via an intuitive fluent interface.
5
6```php
7use Symfony\Component\Finder\Finder;
8
9$finder = new Finder();
10
11$iterator = $finder
12  ->files()
13  ->name('*.php')
14  ->depth(0)
15  ->size('>= 1K')
16  ->in(__DIR__);
17
18foreach ($iterator as $file) {
19    print $file->getRealpath()."\n";
20}
21```
22
23The iterator returns instances of [Symfony\Component\Finder\SplFileInfo\SplFileInfo][1].
24Besides the build-in methods inherited from [\SplFileInfo][2] (`getPerms()`, `getSize()`, ...),
25you can also use `getRelativePath()` and `getRelativePathname()`. Read the
26[official documentation][3] for more information.
27
28But you can also use it to find files stored remotely like in this example where
29we are looking for files on Amazon S3:
30
31```php
32$s3 = new \Zend_Service_Amazon_S3($key, $secret);
33$s3->registerStreamWrapper("s3");
34
35$finder = new Finder();
36$finder->name('photos*')->size('< 100K')->date('since 1 hour ago');
37foreach ($finder->in('s3://bucket-name') as $file) {
38    print $file->getFilename()."\n";
39}
40```
41
42Resources
43---------
44
45You can run the unit tests with the following command:
46
47    $ cd path/to/Symfony/Component/Finder/
48    $ composer install
49    $ phpunit
50
51[1]: http://api.symfony.com/2.5/Symfony/Component/Finder/SplFileInfo.html
52[2]: http://php.net/splfileinfo
53[3]: https://symfony.com/doc/current/components/finder.html#usage
54