Server : Apache/2.4.18 (Ubuntu) System : Linux canvaswebdesign 3.13.0-71-generic #114-Ubuntu SMP Tue Dec 1 02:34:22 UTC 2015 x86_64 User : oppastar ( 1041) PHP Version : 7.0.33-0ubuntu0.16.04.15 Disable Function : pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority, Directory : /usr/share/doc/php-symfony-finder/ |
Upload File : |
Finder Component ================ Finder finds files and directories via an intuitive fluent interface. ```php 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"; } ``` The iterator returns instances of [Symfony\Component\Finder\SplFileInfo\SplFileInfo][1]. Besides the build-in methods inherited from [\SplFileInfo][2] (`getPerms()`, `getSize()`, ...), you can also use `getRelativePath()` and `getRelativePathname()`. Read the [official documentation][3] for more information. But you can also use it to find files stored remotely like in this example where we are looking for files on Amazon S3: ```php $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"; } ``` [1]: http://api.symfony.com/2.5/Symfony/Component/Finder/SplFileInfo.html [2]: http://php.net/splfileinfo [3]: https://symfony.com/doc/current/components/finder.html#usage