Skip to content

Generate a dependency tree visualization for Composer data

License

Notifications You must be signed in to change notification settings

tony84727/dependency_tree

 
 

Repository files navigation

Composer dependency tree visualization

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.

Contents

Demo

Full demo at https://dependency.markfullmer.com

Simple tree

Screenshot of dependency tree

Complex tree

Screenshot of complex dependency tree

Basic usage

  1. Require this library to your PHP project:
composer require markfullmer/dependency_tree
  1. Ensure the library is autoloaded in your PHP file:
use markfullmer\DependencyTree;
  1. 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>
  1. Supply the contents of composer.json and composer.lock files as arguments and generate the tree. (Change the third parameter to TRUE to print version information.)
  $data = DependencyTree::generateTree($root, $lock, FALSE);
  1. Render the resulting data via Javascript, supplying the data and an HTML target ID.
  echo '
    <script>
      dependencyTree('. $data .');
    </script>
  ';

Similar libraries

Drupal integration

A Drupal module that provides this functionality to sites directly is available at https://drupal.org/project/composer_dependency_tree

About

Generate a dependency tree visualization for Composer data

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • JavaScript 97.4%
  • PHP 1.6%
  • Other 1.0%