markfullmer/dependency_tree

Generate a Composer dependency tree visualization

Installs: 6 680

Dependents: 0

Suggesters: 0

Security: 0

Stars: 15

Watchers: 2

Forks: 2

Open Issues: 0

Language:JavaScript

Type:project

1.0.1 2021-03-05 13:06 UTC

This package is auto-updated.

Last update: 2024-04-14 07:54:20 UTC


README

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