class ClassFinder (View source)

Provides method for searching class files in the file system.

Methods

__construct()

Creates a new PathFinder instance.

setFileExtensions(array $extensions)

Sets list of dot included file extensions to use for finding files.

string|false
findFile(string $class, array $prefixPaths, array $basePaths = [], bool $useIncludePath = false)

Attempts to find a file for the given class from given paths.

Details

__construct()

Creates a new PathFinder instance.

setFileExtensions(array $extensions)

Sets list of dot included file extensions to use for finding files.

If no list of extensions is provided, the extension array defaults to just '.php'.

Parameters

array $extensions Array of dot included file extensions to use

string|false findFile(string $class, array $prefixPaths, array $basePaths = [], bool $useIncludePath = false)

Attempts to find a file for the given class from given paths.

Both lists of paths must be given as arrays with keys indicating the namespace. Empty string can be used for the paths that apply to all Classes. Each value must be an array of paths.

Parameters

string $class Full name of the class
array $prefixPaths List of paths used for PSR-4 file search
array $basePaths List of paths used for PSR-0 file search
bool $useIncludePath Whether to use paths in include_path for PSR-0 search or not

Return Value

string|false Path to the class file or false if not found