PHP code example of nusje2000 / dependency-graph

1. Go to this page and download the library: Download nusje2000/dependency-graph 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/ */

    

nusje2000 / dependency-graph example snippets


use Nusje2000\DependencyGraph\Cache\FileCache;
use Nusje2000\DependencyGraph\DependencyGraph;

// By default the DependencyGraph won't cache the result
$graph = DependencyGraph::build('/path/to/project/root');

// Using the FileCache to cache the dependency graph
$graph = DependencyGraph::build('/path/to/project/root', null, new FileCache());

use Nusje2000\DependencyGraph\DependencyGraph;

// building the dependency graph
$graph = DependencyGraph::build('/path/to/project/root');

// get the root path
$graph->getRootPath();

// get all packages
$packages = $graph->getPackages();

// checking if a package exists
$graph->hasPackage('foo/foo-pacakge');

// getting a specific package
$fooPackage = $graph->getPackage('foo/foo-pacakge');
$fooPackage->getName(); // return the name of the package (foo/foo-pacakge)
$fooPackage->getDependencies(); // returns a list of dependencies
$fooPackage->getPackageLocation(); // returns the location of the package