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
$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/
Joshua Behrens
Anthony K GROSS (Original author)
Code and documentation copyright 2020. Code released under the MIT license.