1. Go to this page and download the library: Download borsch/finder 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/ */
borsch / finder example snippets
use Borsch\FileSystem\Finder;
foreach (Finder::create()->in(__DIR__) as $file) {
// $file is an instance of SplFileInfo
}
use Borsch\FileSystem\Finder;
foreach (Finder::create()->files()->in(__DIR__) as $file) {
// $file is an instance of SplFileInfo
}
foreach (Finder::create()->directories()->in(__DIR__) as $file) {
// $file is an instance of SplFileInfo
}
use Borsch\FileSystem\Finder;
foreach (Finder::create()->in(__DIR__.'/*/*/test') as $file) {
// $file is an instance of SplFileInfo
}
foreach (Finder::create()->in(__DIR__)->in('/home/borsch/docs') as $file) {
// $file is an instance of SplFileInfo
}
// Multidimentional array of any depth can be used
$finder = new Finder();
$finder->in([
__DIR__,
'/home/borsch/docs',
[
'/some/other/path',
[
'/some/more/other/path'
]
]
]);
foreach ($finder as $file) {
// $file is an instance of SplFileInfo
}
use Borsch\FileSystem\Finder;
foreach (Finder::create()->in(__DIR__)->sortByName() as $file) {
// $file is an instance of SplFileInfo
}
$finder = Finder::create()->in(__DIR__)->sort(function (SplFileInfo $a, SplFileInfo $b) {
// Equivalent to the method sortByName()
return strcmp($a->getFilename(), $b->getFilename())
});
foreach ($finder as $file) {
// $file is an instance of SplFileInfo
}
use Borsch\FileSystem\Finder;
$finder = Finder::create()->in(__DIR__)->filter(function (SplFileInfo $current) {
// Remove index.php files
return $current->getBasename() !== 'index.php';
});
foreach ($finder as $file) {
// $file is an instance of SplFileInfo
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.