srmilon/graph-composer

Dependency graph visualization for composer.json

v1.0.0 2015-11-17 00:38 UTC

This package is not auto-updated.

Last update: 2024-04-06 13:22:24 UTC


README

Graph visualization for your project's composer.json and its dependencies:

dependency graph for graph-composer

Table of contents

Usage

Once clue/graph-composer is installed, you can use it via command line like this.

graph-composer show

The show command creates a dependency graph for the given project path and opens the default desktop image viewer for you:

$ php graph-composer.phar show ~/path/to/your/project
  • It accepts an optional argument which is the path to your project directory or composer.json file (defaults to checking the current directory for a composer.json file).

  • You may optionally pass an --format=[svg/svgz/png/jpeg/...] option to set the image type (defaults to svg).

graph-composer export

The export command works very much like the show command, but instead of opening your default image viewer, it will write the resulting graph to STDOUT or into an image file:

$ php graph-composer.phar export ~/path/to/your/project
  • It accepts an optional argument which is the path to your project directory or composer.json file (defaults to checking the current directory for a composer.json file).

  • It accepts an additional optional argument which is the path to write the resulting image to. Its file extension also sets the image format (unless you also explicitly pass the --format option). Example call:

    $ php graph-composer.phar export ~/path/to/your/project export.png

    If this argument is not given, it defaults to writing to STDOUT, which may be useful for scripting purposes:

    $ php graph-composer.phar export ~/path/to/your/project | base64
  • You may optionally pass an --format=[svg/svgz/png/jpeg/...] option to set the image type (defaults to svg).

Install

You can grab a copy of clue/graph-composer in either of the following ways.

As a phar (recommended)

You can simply download a pre-compiled and ready-to-use version as a Phar to any directory. Simply download the latest graph-composer.phar file from our releases page:

Latest release

Additionally, you'll have to install GraphViz (dot executable). Users of Debian/Ubuntu-based distributions may simply invoke:

$ sudo apt-get install graphviz

Windows users have to download GraphViZ for Windows and remaining users should install from GraphViz homepage.

That's it already. You can now verify everything works by running this:

$ cd ~/Downloads
$ php graph-composer.phar --version

If you prefer a global (system-wide) installation without having to type the .phar extension each time, you may simply invoke:

$ chmod 0755 graph-composer.phar
$ sudo mv graph-composer.phar /usr/local/bin/graph-composer

You can verify everything works by running:

$ graph-composer --version

Updating phar

There's no separate update procedure, simply download the latest release again and overwrite the existing phar.

Installation using Composer

Alternatively, you can also install graph-composer as part of your development dependencies. You will likely want to use the require-dev section to exclude graph-composer in your production environment.

This method also requires PHP 5.3+, GraphViz and, of course, Composer.

You can either modify your composer.json manually or run the following command to include the latest tagged release:

$ composer require --dev clue/graph-composer

Now you should be able to invoke the following command in your project root:

$ ./vendor/bin/graph-composer show

Alternatively, you can install this globally for your user by running:

$ composer global require clue/graph-composer

Now, assuming you have ~/.composer/vendor/bin in your path, you can invoke the following command:

$ graph-composer show ~/path/to/your/project

Note: You should only invoke and rely on the main graph-composer bin file. Installing this project as a non-dev dependency in order to use its source code as a library is not supported.

Updating dependency

Just run composer update clue/graph-composer to update to the latest release.

If you installed it globally via composer you can run composer global update clue/graph-composer instead.

Manual Installation from Source

This project requires PHP 5.3+, Composer and GraphViz:

$ sudo apt-get install php5-cli graphviz
$ git clone https://github.com/clue/graph-composer.git
$ cd graph-composer
$ curl -s https://getcomposer.org/installer | php
$ php composer.phar install

You can now verify everything works by running graph-composer like this:

$ php bin/graph-composer show

If you want to build the above mentioned graph-composer.phar yourself, you have to install clue/phar-composer and can simply invoke:

$ php phar-composer.phar build ~/workspace/graph-composer

Updating manually

$ git pull
$ php composer.phar install

License

MIT