PHP code example of org_heigl / filefinder

1. Go to this page and download the library: Download org_heigl/filefinder library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

org_heigl / filefinder example snippets


$finder = new \Org_Heigl\FileFinder\FileFinder();
$finder->addFilter(new \Org_Heigl\FileFinder\Filter\FileExtension('jpg'));
$finder->addDirectory($dir);
$list = $finder->find();
// $list will be an \Org_Heigl\FileFinder\FileList-Object containing all Files with the extension 'jpg' inside 

$finder = new \Org_Heigl\FileFinder\FileFinder();
$finder->addFilter(new \Org_Heigl\FileFinder\Filter\FileExtension('jpg'));
$finder->addDirectory($dir);
$finder->setFileList(new MyPrettyFileList())
$list = $finder->find();
// $list will be the MyPrettyFileList-Object containing all Files with the extension 'jpg' inside 

$finder = new \Org_Heigl\FileFinder\FileFinder();
$finder->addFilter(new \Org_Heigl\FileFinder\Filter\FileExtension('php'));
$finder->addFilter(new \Org_Heigl\FileFinder\Filter\ClassIsInstanceof('\Iterator'));
$finder->setFileList(new \Org_Heigl\FileFinder\ClassMapList());
$finder->addDirectory($dir);
$list = $finder->find();
// $list now contains the classname as key and the filepath as value

$finder = new \Org_Heigl\FileFinder\FileFinder();
$finder->addDirectory($dir);
$list = $finder->find();
$list->sort(new \Org_Heigl\FileFinder\Sorter\MTime());
// $list now is sorted by MTime ascending.
$dir
new FileStart('')
new ClassIsInstanceOf(['InterfaceOne','\Org_Heigl\FileFinder\FilterInterface']);