This is a simple PHP library that will take a standard composer.json
file and composer.lock
file and generate a dependency tree, using the D3JS visualization known as the collapsible tree.
Full demo at https://dependency.markfullmer.com
- Require this library to your PHP project:
composer require markfullmer/dependency_tree
- Ensure the library is autoloaded in your PHP file:
use markfullmer\DependencyTree;
- Copy or reference the
d3.dependencyTree.js
file from this library into your project and load it into a web page, along with the underlying D3JS API library.
<script src='https://d3js.org/d3.v4.min.js'></script>
<script src='./js/d3.dependencyTree.js'></script>
- Supply the contents of
composer.json
andcomposer.lock
files as arguments and generate the tree. (Change the third parameter toTRUE
to print version information.)
$data = DependencyTree::generateTree($root, $lock, FALSE);
- Render the resulting data via Javascript, supplying the data and an HTML target ID.
echo '
<script>
dependencyTree('. $data .');
</script>
';
-
https://github.com/fzaninotto/DependencyWheel : "This experiment visualizes package dependencies using an interactive disc. Each disc section represents a dependency, and links between arcs materialize these dependencies."
-
https://github.com/clue/graph-composer : "Graph visualization for your project's
composer.json
and its dependencies"
A Drupal module that provides this functionality to sites directly is available at https://drupal.org/project/composer_dependency_tree