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 3719c70870 updated minimum PHP version to 5.3.3
5.3.3 has some interesting fixes and this is the version used by
Redhat 6 and Debian 6
2012-05-07 10:29:11 +02:00
..
Comparator [Finder][Comparator] not equal operator 2012-04-18 13:59:47 +02:00
Iterator Fix some cs 2012-05-04 00:17:06 +02:00
Tests fixed CS 2012-05-01 15:23:48 +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 fixed CS 2012-05-01 15:23:48 +02:00
Glob.php [Phpdoc] Cleaning/fixing 2011-04-23 15:18:47 +00: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