PHPackages                             digilist/dependency-graph - 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. [Utility &amp; Helpers](/categories/utility)
4. /
5. digilist/dependency-graph

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

digilist/dependency-graph
=========================

Dependency Graph Resolver in PHP

v0.4.3(2mo ago)19439.1k—5.7%7[1 PRs](https://github.com/digilist/dependency-graph/pulls)5MITPHPPHP &gt;=8.1CI passing

Since Apr 18Pushed 2mo ago1 watchersCompare

[ Source](https://github.com/digilist/dependency-graph)[ Packagist](https://packagist.org/packages/digilist/dependency-graph)[ RSS](/packages/digilist-dependency-graph/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (4)Dependencies (6)Versions (9)Used By (5)

[![PHP](https://github.com/digilist/dependency-graph/actions/workflows/php.yml/badge.svg)](https://github.com/digilist/dependency-graph/actions/workflows/php.yml)

PHP DependencyGraph
===================

[](#php-dependencygraph)

This library provides a simple [Dependency Graph](http://en.wikipedia.org/wiki/Dependency_graph) resolver. It supports multiple root nodes which are detected automatically.

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

[](#installation)

You can install this library with Composer by requiring `digilist/dependency-graph`

Example Usage:
--------------

[](#example-usage)

There are two ways to define dependencies. One way is to define the dependencies directly on the node by calling the `dependsOn` method. By using this method you have to add the nodes manually to the graph (or at least the root nodes).

```
$nodeA = new DependencyNode('A');
$nodeB = new DependencyNode('B');
$nodeC = new DependencyNode('C');
$nodeD = new DependencyNode('D');
$nodeE = new DependencyNode('E');

$nodeA->dependsOn($nodeB);
$nodeA->dependsOn($nodeD);
$nodeB->dependsOn($nodeC);
$nodeB->dependsOn($nodeE);
$nodeC->dependsOn($nodeD);
$nodeC->dependsOn($nodeE);

$graph = new DependencyGraph();
$graph->addNode($nodeA);
$resolved = DependencyGraph->resolve(); // returns [D, E, C, B, A]
```

Alternatively, you can define the dependencies on the graph. By using this method, the root node will be automatically detected.

```
$graph = new DependencyGraph();

$nodeA = new DependencyNode('A');
$nodeB = new DependencyNode('B');
$nodeC = new DependencyNode('C');
$nodeD = new DependencyNode('D');
$nodeE = new DependencyNode('E');

$graph->addDependency($nodeA, $nodeB);
$graph->addDependency($nodeA, $nodeD);
$graph->addDependency($nodeB, $nodeC);
$graph->addDependency($nodeB, $nodeE);
$graph->addDependency($nodeC, $nodeD);
$graph->addDependency($nodeC, $nodeE);

$resolved = DependencyGraph->resolve(); // returns [D, E, C, B, A]
```

The passed payload to DependencyNode can be any arbitrary PHP element (primitive, array, object, resource...).

###  Health Score

59

—

FairBetter than 99% of packages

Maintenance86

Actively maintained with recent releases

Popularity47

Moderate usage in the ecosystem

Community23

Small or concentrated contributor base

Maturity67

Established project with proven stability

 Bus Factor2

2 contributors hold 50%+ of commits

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 ~663 days

Recently: every ~857 days

Total

7

Last Release

70d ago

PHP version history (3 changes)v0.1PHP &gt;=5.3

v0.4PHP &gt;=8.2

v0.4.2PHP &gt;=8.1

### Community

Maintainers

![](https://www.gravatar.com/avatar/71cd933b37f7c5ca10b7e36e8c16922773fe15764ba7f2cc53f278e272d24bff?d=identicon)[digilist](/maintainers/digilist)

---

Top Contributors

[![digilist](https://avatars.githubusercontent.com/u/833667?v=4)](https://github.com/digilist "digilist (12 commits)")[![shyim](https://avatars.githubusercontent.com/u/6224096?v=4)](https://github.com/shyim "shyim (5 commits)")[![jasir](https://avatars.githubusercontent.com/u/115066?v=4)](https://github.com/jasir "jasir (3 commits)")[![mitelg](https://avatars.githubusercontent.com/u/6985627?v=4)](https://github.com/mitelg "mitelg (3 commits)")[![aragon999](https://avatars.githubusercontent.com/u/6317761?v=4)](https://github.com/aragon999 "aragon999 (2 commits)")[![JanWennrich](https://avatars.githubusercontent.com/u/42703348?v=4)](https://github.com/JanWennrich "JanWennrich (2 commits)")

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StylePHP CS Fixer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/digilist-dependency-graph/health.svg)

```
[![Health](https://phpackages.com/badges/digilist-dependency-graph/health.svg)](https://phpackages.com/packages/digilist-dependency-graph)
```

###  Alternatives

[matthiasnoback/php-workshop-tools

261.8k](/packages/matthiasnoback-php-workshop-tools)

PHPackages © 2026

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