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
2013-01-04 17:58:00 +01:00
..
Adapter fixed CS 2012-12-20 08:41:17 +01:00
Comparator Fixed most of the docblocks/unused namespaces 2012-12-19 08:09:49 +01:00
Exception fixed CS 2012-12-11 11:49:22 +01:00
Expression Fixed typos 2012-12-14 22:27:02 +00:00
Iterator Fixed most of the docblocks/unused namespaces 2012-12-19 08:09:49 +01:00
Shell fixed CS 2012-12-20 08:41:17 +01:00
Tests [Finder] Added support for GLOB patterns in the directories passed to the in() method. 2013-01-02 12:29:42 +01:00
.gitattributes Fix export-ignore on Windows 2012-11-08 10:51:48 +01:00
.gitignore made usage of Composer autoloader for subtree-split unit tests 2012-11-09 14:10:06 +01:00
CHANGELOG.md [Finder] Added support for GLOB patterns in the directories passed to the in() method. 2013-01-02 12:29:42 +01:00
composer.json Removed useless branch alias for dev-master in composer.json 2012-12-06 11:00:55 +01:00
Finder.php [Finder] Added support for GLOB patterns in the directories passed to the in() method. 2013-01-02 12:29:42 +01:00
Glob.php fixed CS 2012-07-09 14:54:20 +02:00
LICENSE updated license year 2013-01-04 17:58:00 +01:00
phpunit.xml.dist made usage of Composer autoloader for subtree-split unit tests 2012-11-09 14:10:06 +01:00
README.md made usage of Composer autoloader for subtree-split unit tests 2012-11-09 14:10:06 +01:00
SplFileInfo.php Fixed most of the docblocks/unused namespaces 2012-12-19 08:09:49 +01: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:

$ cd path/to/Symfony/Component/Finder/
$ composer.phar install --dev
$ phpunit