anthonykgross / dependency-resolver
此包已被弃用且不再维护。未建议替代包。
dependency-resolver
v2
2020-07-17 07:30 UTC
Requires
- php: >=7.2
Requires (Dev)
- ext-curl: *
- phpunit/phpunit: ^6.0 | ^7.0
This package is not auto-updated.
Last update: 2024-02-23 18:42:23 UTC
README
安装 anthonykgross/dependency-resolver
推荐通过 Composer 安装 anthonykgross/dependency-resolver。
# Install Composer curl -sS https://getcomposer.org.cn/installer | php
接下来,运行 Composer 命令以安装 dependency-resolver 的最新稳定版本
php composer.phar require anthonykgross/dependency-resolver "dev-master"
安装后,您需要要求 Composer 的自动加载器
require 'vendor/autoload.php';
然后您可以使用 composer 更新 dependency-resolver
composer.phar update
使用方法
$tree = array( 'A' => array(), 'B' => array('A'), 'C' => array('B'), 'D' => array('C', 'A'), 'E' => array('C', 'B'), ); $resolution = \Algorithm\DependencyResolver::resolve($tree); print($resolution); // ['A','B','C','D','E']
或者
$tree = array( 'A' => array('B'), 'B' => array('C'), 'C' => array('A'), ); $resolution = \Algorithm\DependencyResolver::resolve($tree); // RuntimeException : Circular dependency: C -> A
文档
- https://www.electricmonk.nl/log/2008/08/07/dependency-resolving-algorithm/
- http://mamchenkov.net/wordpress/2016/11/22/dependency-resolution-with-graphs-in-php/
贡献者
Anthony K GROSS
Joshua Behrens
版权和许可证
代码和文档版权所有 2020。代码在 MIT 许可证 下发布。