heptacom/dependency-resolver

Basis library to resolve dependencies with graph / tree

1.0.0 2024-11-02 22:00 UTC

This package is auto-updated.

Last update: 2024-12-02 22:13:03 UTC


README

The recommended way to install heptacom/dependency-resolver is through Composer.

Next, run the Composer command to install the latest stable version of dependency-resolver:

composer require heptacom/dependency-resolver

You can then later update dependency-resolver using composer:

composer update heptacom/dependency-resolver

Usage

$tree  = [
    'A' => [],
    'B' => ['A'],
    'C' => ['B'],
    'D' => ['C', 'A'],
    'E' => ['C', 'B'],
];
$resolution = (new \Heptacom\DependencyResolver\DependencyResolver())->resolve($tree);
print($resolution);
// ['A','B','C','D','E']

OR

$tree  = [
    'A' => ['B'],
    'B' => ['C'],
    'C' => ['A'],
];
$resolution = (new \Heptacom\DependencyResolver\DependencyResolver())->resolve($tree);
// RuntimeException : Circular dependency: C -> A

Documentation

Contributors

Joshua Behrens

Anthony K GROSS (Original author)

Copyright and license

Code and documentation copyright 2020. Code released under the MIT license.