PHP code example of anthonykgross / dependency-resolver

1. Go to this page and download the library: Download anthonykgross/dependency-resolver library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

anthonykgross / dependency-resolver example snippets




$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
bash
# Install Composer
curl -sS https://getcomposer.org/installer | php
bash
php composer.phar