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.

Maintainers

Package info

gitlab.com/a.adach/static-class-finder

Issues

pkg:composer/adachsoft/static-class-finder

Statistics

Installs: 2

Dependents: 1

Suggesters: 0

Stars: 0

v0.1.0 2026-03-06 08:58 UTC

This package is auto-updated.

Last update: 2026-03-06 08:04:00 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, and psr-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.";
}