PHP code example of rkr / class-finder
1. Go to this page and download the library: Download rkr/class-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/ */
rkr / class-finder example snippets
use Kir\ClassFinder\ClassFinder;
$startDir = __DIR__ . '/src';
$classNames = ClassFinder::findClassesFromDirectory($startDir);
print_r(iterator_to_array($classNames));
// Kir\ClassFinder\NodeVisitor
// Kir\ClassFinder\ClassFinder
// Kir\ClassFinder\ClassTools
// Kir\ClassFinder\ClassFinderResult
// Kir\ClassFinder\ClassFile
use Kir\ClassFinder\ClassFinder;
//region Gather the files
$startDir = __DIR__ . '/src';
$directory = new RecursiveDirectoryIterator($startDir, FilesystemIterator::FOLLOW_SYMLINKS | FilesystemIterator::SKIP_DOTS | FilesystemIterator::KEY_AS_PATHNAME | FilesystemIterator::CURRENT_AS_PATHNAME);
$iterator = new RecursiveIteratorIterator($directory);
$files = new CallbackFilterIterator($iterator, fn(string $path) => preg_match('{\\.p(hp\\d?|html)$}i', $path));
//endregion
$classNames = ClassFinder::findClassesFromIterableFileList($files);
print_r(iterator_to_array($classNames));
// Kir\ClassFinder\NodeVisitor
// Kir\ClassFinder\ClassFinder
// Kir\ClassFinder\ClassTools
// Kir\ClassFinder\ClassFinderResult
// Kir\ClassFinder\ClassFile