<?php
use Symfony\Component\Finder\Finder;
$rootDir = __DIR__;
/**
* searching in filesystem with Finder
*/
$finder = new Finder();
$finder->files()
->in($rootDir) // dir path string
->name('*.php')
->sortByName();
echo '<b>Find all php files in dir:</b>' . PHP_EOL;
foreach($finder as $file) {
echo $file->getFileName() . PHP_EOL;
}
$finder->contains('dump');
echo '<b>Find php files containing "dump":</b>' . PHP_EOL;
foreach($finder as $file) {
echo $file->getFileName() . PHP_EOL;
}