PHPackages                             thomasmarinissen/class-dependency-resolver - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. thomasmarinissen/class-dependency-resolver

ActiveLibrary

thomasmarinissen/class-dependency-resolver
==========================================

A Class Dependency Resolver for PHP

v0.1.3(1y ago)05MITPHPPHP ^8.3

Since Sep 25Pushed 1y ago1 watchersCompare

[ Source](https://github.com/ThomasMarinissen/class-dependency-resolver)[ Packagist](https://packagist.org/packages/thomasmarinissen/class-dependency-resolver)[ RSS](/packages/thomasmarinissen-class-dependency-resolver/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (4)Dependencies (6)Versions (7)Used By (0)

Class Dependency Resolver
=========================

[](#class-dependency-resolver)

Description
-----------

[](#description)

The PHP Class Dependency Resolver is a library designed to facilitate providing context to Large Language Models by resolving dependencies of PHP classes/files. It maps fully qualified class names, interfaces, and traits to their corresponding file paths and manages the direct dependencies between files. The main entry point to the library is the `Resolver` class.

Table of Contents
-----------------

[](#table-of-contents)

- [Installation](#installation)
- [Basic Usage](#basic-usage)
- [Configuration](#configuration)
- [Examples](#examples)
- [Contributing](#contributing)
- [Testing](#testing)
- [License](#license)

Installation
------------

[](#installation)

To install the Class Dependency Resolver library, use Composer:

```
composer require thomasmarinissen/class-dependency-resolver
```

Ensure that your PHP version is compatible (PHP 8.3 or higher) and that you have Composer installed on your system.

Basic Usage
-----------

[](#basic-usage)

To use the Class Dependency Resolver, you need to initialize the `Resolver` class with the directories you want to scan for PHP files. Here is a basic example:

```
use Thomasmarinissen\ClassDependencyResolver\Resolver;

// Directories to scan
$directories = ['/path/to/your/php/files'];

// Initialize the Resolver
$resolver = new Resolver($directories);

// Get the file path for a specific class
$filePath = $resolver->filePathByName('Your\Namespace\YourClass');

// Get the dependencies for a specific file
$dependencies = $resolver->dependenciesByFile('/path/to/your/php/files/YourClass.php');
```

This example demonstrates how to initialize the resolver, build the dependency maps, and retrieve file paths and dependencies.

Configuration
-------------

[](#configuration)

The `Resolver` class allows you to specify the PHP version you want to target when parsing files. By default, it uses the host's PHP version. You can specify a different version by passing a `PhpVersion` instance to the constructor:

```
use PhpParser\PhpVersion;
use Thomasmarinissen\ClassDependencyResolver\Resolver;

// Specify PHP version
$phpVersion = PhpVersion::fromString('8.3');

// Initialize the Resolver with a specific PHP version
$resolver = new Resolver(['/path/to/your/php/files'], $phpVersion);
```

This allows you to ensure compatibility with different PHP versions when resolving dependencies.

Examples
--------

[](#examples)

### Example 1: Resolving Class Dependencies

[](#example-1-resolving-class-dependencies)

```
use Thomasmarinissen\ClassDependencyResolver\Resolver;

$directories = ['/path/to/your/php/files'];
$resolver = new Resolver($directories);

$className = 'App\Controllers\HomeController';
$filePath = $resolver->filePathByName($className);
$dependencies = $resolver->dependenciesByName($className);

echo "File path for $className: $filePath\n";
echo "Dependencies: " . implode(', ', $dependencies) . "\n";
```

### Example 2: Handling Multiple Directories

[](#example-2-handling-multiple-directories)

```
use Thomasmarinissen\ClassDependencyResolver\Resolver;

$directories = ['/path/to/first/directory', '/path/to/second/directory'];
$resolver = new Resolver($directories);

$filePath = $resolver->filePathByName('Another\Namespace\AnotherClass');

echo "File path: $filePath\n";
```

### Example 3: Resolving Class Dependencies by file path

[](#example-3-resolving-class-dependencies-by-file-path)

```
use Thomasmarinissen\ClassDependencyResolver\Resolver;

$directories = ['/path/to/first/directory'];
$resolver = new Resolver($directories);

$filePath = '/path/to/first/directory/AnotherClass.php';

$dependencies = $resolver->dependenciesByFile($filePath);

echo "Dependencies: " . implode(', ', $dependencies) . "\n";
```

These examples illustrate how to resolve dependencies for classes or files and handle multiple directories.

Contributing
------------

[](#contributing)

Contributions are welcome! If you wish to contribute to the Class Dependency Resolver project, please follow these guidelines:

1. Fork the repository.
2. Create a new branch for your feature or bugfix.
3. Make your changes and ensure that all tests pass.
4. Submit a pull request with a clear description of your changes.

Please adhere to the coding standards and include tests for any new functionality.

Testing
-------

[](#testing)

To run the tests for the Class Dependency Resolver library, you need to have PHPUnit installed. You can run the tests using the following command:

```
composer test
```

This command will execute the PHPUnit tests defined in the `tests` directory. Ensure that all tests pass before submitting any contributions.

License
-------

[](#license)

This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.

###  Health Score

26

—

LowBetter than 43% of packages

Maintenance38

Infrequent updates — may be unmaintained

Popularity4

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity48

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~0 days

Total

4

Last Release

589d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/adf2b14cceb05ae6d6e5044234032afabb190fd10dd2f01714381870d4f56338?d=identicon)[ThomasMarinissen](/maintainers/ThomasMarinissen)

---

Top Contributors

[![ThomasMarinissen](https://avatars.githubusercontent.com/u/11422575?v=4)](https://github.com/ThomasMarinissen "ThomasMarinissen (5 commits)")

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StyleLaravel Pint

Type Coverage Yes

### Embed Badge

![Health badge](/badges/thomasmarinissen-class-dependency-resolver/health.svg)

```
[![Health](https://phpackages.com/badges/thomasmarinissen-class-dependency-resolver/health.svg)](https://phpackages.com/packages/thomasmarinissen-class-dependency-resolver)
```

###  Alternatives

[psy/psysh

An interactive shell for modern PHP.

9.8k545.6M712](/packages/psy-psysh)[zircote/swagger-php

Generate interactive documentation for your RESTful API using PHP attributes (preferred) or PHPDoc annotations

5.3k132.9M468](/packages/zircote-swagger-php)[vimeo/psalm

A static analysis tool for finding errors in PHP applications

5.8k77.5M6.7k](/packages/vimeo-psalm)[behat/behat

Scenario-oriented BDD framework for PHP

4.0k96.8M1.9k](/packages/behat-behat)[symfony/maker-bundle

Symfony Maker helps you create empty commands, controllers, form classes, tests and more so you can forget about writing boilerplate code.

3.4k111.1M563](/packages/symfony-maker-bundle)[infection/infection

Infection is a Mutation Testing framework for PHP. The mutation adequacy score can be used to measure the effectiveness of a test set in terms of its ability to detect faults.

2.2k26.2M1.8k](/packages/infection-infection)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
