05b2c4eec0
* 2.5: Remove Spaceless Blocks From Twig Templates Validate locales sets intos translator [Console] Remove estimated field from debug_nomax Fix UserPassword validator translation Remove Spaceless Blocks from Twig Form Templates [Validator] remove wrong deprecation message fixed typo [HttpFoundation] Fix to prevent magic bytes injection in JSONP responses (Prevents CVE-2014-4671) added regression test fix issue #8171 on configuration tree for twig extension -- pairing up with @cordoval [HttpFoundation] Fix wrong assertion in Response test [Upgrade] Fixed markdown syntax [2.3][Form] Cleanup & fix phpdocs Added verbosity methods |
||
---|---|---|
.. | ||
Adapter | ||
Comparator | ||
Exception | ||
Expression | ||
Iterator | ||
Shell | ||
Tests | ||
.gitignore | ||
CHANGELOG.md | ||
composer.json | ||
Finder.php | ||
Glob.php | ||
LICENSE | ||
phpunit.xml.dist | ||
README.md | ||
SplFileInfo.php |
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
$ phpunit