PHPackages                             iyoworks/dependency-sorter - 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. iyoworks/dependency-sorter

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

iyoworks/dependency-sorter
==========================

Sorts items according to a list of dependencies

141[1 PRs](https://github.com/blessingefkt/DependencySorter/pulls)PHP

Since Oct 24Pushed 11y ago1 watchersCompare

[ Source](https://github.com/blessingefkt/DependencySorter)[ Packagist](https://packagist.org/packages/iyoworks/dependency-sorter)[ RSS](/packages/iyoworks-dependency-sorter/feed)WikiDiscussions develop Synced 2mo ago

READMEChangelogDependenciesVersions (2)Used By (0)

DependencySorter
================

[](#dependencysorter)

Sorts items according to a list of dependencies.

This package provides 2 interfaces:

 Iyoworks\\DependencySorter\\SortableInterface implemented by objects that conducting the sorting Iyoworks\\DependencySorter\\DependableInterface implemented by objects that are to be sortedItems can be passed to the sorter in a group via `Sorter::add(array)`, or individuallay via `Sorter::addItem(item, dependencies)`.

The provided `Sorter` implementaion can get dependencies from:

- a comma delimted string
- an array
- an object that implements `DependableInterface`

```
$sorter = new Iyoworks\DependencySorter\Sorter;
$sorter->add( array(
	'couple' => 'father, mother'
	'mother' => 'father',
	'father' => null,
	));
$orderedItems = $sorter->sort();

```

The sorted list of items would be:

```
Array
(
    [0] => father
    [1] => mother
    [2] => couple
)

```

Missing Dependencies
--------------------

[](#missing-dependencies)

Items missing dependencies are identified.

```
$sorter = new Iyoworks\DependencySorter\Sorter;
$sorter->add( array(
	'couple' => 'father, mother'
	'mother' => 'child',
	'father' => 'mother',
	) );
$orderedItems = $sorter->sort(); //returns an empty array

```

The missing dependencies can be retrieved

```
$missing = $sorter->getMissing();

```

The missing items would be:

```
Array
(
    [mother] => Array
        (
            [child] => child
        )
)

```

Missing dependencies of an item can be retrieved individually

```
$missing = $sorter->getMissing('mother');

```

You can check if an item has missing dependencies

```
$sorter->hasMissing($item);

```

You can also check if an item is a missing dependency

```
$sorter->isMissing($dep);

```

Circular Dependencies
---------------------

[](#circular-dependencies)

Circular dependencies are identified.

```
$sorter = new Iyoworks\DependencySorter\Sorter;
$sorter->add( array(
	'couple' => 'father, mother'
	'mother' => 'father',
	'father' => 'mother',
	) );
$orderedItems = $sorter->sort(); //returns an empty array
$circular = $sorter->getCircular();

```

The list of circular items would be:

```
Array
(
    [mother] => Array
        (
            [father] => father
        )
    [father] => Array
        (
            [mother] => mother
        )
)

```

The circular dependencies of an item can be retrieved individually.

```
$circular = $sorter->getCircular('father');

```

You can check if an item has circular dependencies

```
$sorter->hasCircular($item);

```

You can also check if an item is a circular dependency

```
$sorter->isCircular($dep);

```

###  Health Score

22

—

LowBetter than 22% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity9

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity43

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 95.7% 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.

### Community

Maintainers

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

---

Top Contributors

[![blessingefkt](https://avatars.githubusercontent.com/u/887992?v=4)](https://github.com/blessingefkt "blessingefkt (22 commits)")[![shengzhao91](https://avatars.githubusercontent.com/u/5084999?v=4)](https://github.com/shengzhao91 "shengzhao91 (1 commits)")

### Embed Badge

![Health badge](/badges/iyoworks-dependency-sorter/health.svg)

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

PHPackages © 2026

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