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
2012-10-04 15:06:11 +02:00
..
Adapter [2.2] [WIP] [Finder] Adding native finders implementations 2012-10-04 15:06:11 +02:00
Comparator [Finder][Comparator] not equal operator 2012-04-18 13:59:47 +02:00
Exception [2.2] [WIP] [Finder] Adding native finders implementations 2012-10-04 15:06:11 +02:00
Expression [2.2] [WIP] [Finder] Adding native finders implementations 2012-10-04 15:06:11 +02:00
Iterator [2.2] [WIP] [Finder] Adding native finders implementations 2012-10-04 15:06:11 +02:00
Shell [2.2] [WIP] [Finder] Adding native finders implementations 2012-10-04 15:06:11 +02:00
Tests [2.2] [WIP] [Finder] Adding native finders implementations 2012-10-04 15:06:11 +02:00
CHANGELOG.md [Finder] '*' and '?' are considered are glob pattern rather than delimiters (fix #4664) 2012-07-02 09:05:19 +02:00
composer.json Revert "raised the minimum version of PHP to 5.3.4 (closes #3856)" 2012-07-15 12:13:51 +02:00
Finder.php [2.2] [WIP] [Finder] Adding native finders implementations 2012-10-04 15:06:11 +02:00
Glob.php fixed CS 2012-07-09 14:54:20 +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 fixed CS 2012-07-09 17:06:57 +02: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