heptacom / dependency-resolver
Basis library to resolve dependencies with graph / tree
1.0.0
2024-11-02 22:00 UTC
Requires
- php: >=8.3
Replaces
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
- https://www.electricmonk.nl/log/2008/08/07/dependency-resolving-algorithm/
- http://mamchenkov.net/wordpress/2016/11/22/dependency-resolution-with-graphs-in-php/
Contributors
Joshua Behrens
Anthony K GROSS (Original author)
Copyright and license
Code and documentation copyright 2020. Code released under the MIT license.