adachsoft / static-class-finder
A robust, standalone PHP library that resolves the file path of a class based on its Fully Qualified Class Name (FQCN) using only static Composer maps.
Installs: 0
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Forks: 0
pkg:composer/adachsoft/static-class-finder
Requires
- php: ^8.1
Requires (Dev)
- friendsofphp/php-cs-fixer: ^3.92
- phpstan/phpstan: ^2.1
- phpunit/phpunit: ^12.5
This package is not auto-updated.
Last update: 2026-01-07 05:03:46 UTC
README
A robust, zero-dependency PHP library that resolves the file path of a class based on its Fully Qualified Class Name (FQCN) using only static Composer maps.
Features
- No Reflection: Does not load or execute the target class. Safe for files with syntax errors.
- Zero Dependencies: Requires only PHP 8.1+.
- Composer Compatible: Supports
classmap,psr-4, andpsr-0(legacy). - Lazy Loading: Loads Composer maps only when necessary.
Installation
composer require adachsoft/static-class-finder
Usage
use AdachSoft\StaticClassFinder\Locator;
// Initialize with the root path of the target project (where composer.json lives)
$projectRoot = '/var/www/target-project';
$locator = new Locator($projectRoot);
// Locate a class file
$filePath = $locator->locate('Monolog\Logger');
if ($filePath) {
echo "File found: " . $filePath;
// Output: vendor/monolog/monolog/src/Monolog/Logger.php (relative to project root)
} else {
echo "Class not found.";
}