This repository has been archived on 2023-08-20. You can view files and clone it, but cannot push or open issues or pull requests.
symfony/src/Symfony/Component/Finder
Fabien Potencier 335d4eab86 fixed CS
2012-05-21 22:27:15 +02:00
..
Comparator [Finder][Comparator] not equal operator 2012-04-18 13:59:47 +02:00
Iterator merged branch gajdaw/finder_contains_exception_test (PR #4056) 2012-05-11 18:30:27 +02:00
Tests fixed CS 2012-05-21 22:27:15 +02:00
CHANGELOG.md [Finder] added CHANGELOG 2012-04-26 21:57:04 +02:00
composer.json updated minimum PHP version to 5.3.3 2012-05-07 10:29:11 +02:00
Finder.php merged branch jocl/master (PR #4211) 2012-05-18 09:39:34 +02:00
Glob.php fixed CS 2012-05-18 19:42:42 +02:00
LICENSE Updated LICENSE files copyright 2012-02-22 10:10:37 +01:00
phpunit.xml.dist [Components] Tests/Autoloading fixes 2012-05-01 17:51:41 +02:00
README.md [Components] Tests/Autoloading fixes 2012-05-01 17:51:41 +02:00
SplFileInfo.php [Phpdoc] Cleaning/fixing 2011-04-23 15:18:47 +00:00

Finder Component

Finder finds files and directories via an intuitive fluent interface.

use Symfony\Component\Finder\Finder;

$finder = new Finder();

$iterator = $finder
  ->files()
  ->name('*.php')
  ->depth(0)
  ->size('>= 1K')
  ->in(__DIR__);

foreach ($iterator as $file) {
    print $file->getRealpath()."\n";
}

But you can also use it to find files stored remotely like in this example where we are looking for files on Amazon S3:

$s3 = new \Zend_Service_Amazon_S3($key, $secret);
$s3->registerStreamWrapper("s3");

$finder = new Finder();
$finder->name('photos*')->size('< 100K')->date('since 1 hour ago');
foreach ($finder->in('s3://bucket-name') as $file) {
    print $file->getFilename()."\n";
}

Resources

You can run the unit tests with the following command:

phpunit