Skip to content

Dependency graph visualization for composer.json (PHP + Composer) based on mermaid-js

License

Notifications You must be signed in to change notification settings

JBZoo/Composer-Graph

Repository files navigation

JBZoo / Composer-Graph

CI Coverage Status Psalm Coverage Psalm Level CodeFactor
Stable Version Total Downloads Dependents GitHub License

Installation

composer require        jbzoo/composer-graph # For a specific project
composer global require jbzoo/composer-graph # As global tool

# OR use phar file.
wget https://github.com/JBZoo/Composer-Graph/releases/latest/download/composer-graph.phar

Usage

$ php ./vendor/bin/composer-graph --help

Usage:
  build [options]

Options:
  -r, --root=ROOT                The path has to contain "composer.json" and "composer.lock" files [default: "./"]
  -o, --output=OUTPUT            Path to html output. [default: "./build/composer-graph.html"]
  -f, --format=FORMAT            Output format. Available options: html,mermaid [default: "html"]
  -D, --direction=DIRECTION      Direction of graph. Available options: LR,TB,BT,RL [default: "LR"]
  -p, --show-php                 Show PHP-node
  -e, --show-ext                 Show all ext-* nodes (PHP modules)
  -d, --show-dev                 Show all dev dependencies
  -s, --show-suggests            Show not installed suggests packages
  -l, --show-link-versions       Show version requirements in links
  -P, --show-package-versions    Show version of packages
  -O, --abc-order                Strict ABC ordering nodes in graph. It's fine tuning, sometimes it useful.
      --no-progress              Disable progress bar animation for logs. It will be used only for text output format.
      --mute-errors              Mute any sort of errors. So exit code will be always "0" (if it's possible).
                                 It has major priority then --non-zero-on-error. It's on your own risk!
      --stdout-only              For any errors messages application will use StdOut instead of StdErr. It's on your own risk!
      --non-zero-on-error        None-zero exit code on any StdErr message.
      --timestamp                Show timestamp at the beginning of each message.It will be used only for text output format.
      --profile                  Display timing and memory usage information.
      --output-mode=OUTPUT-MODE  Output format. Available options:
                                 text - Default text output format, userfriendly and easy to read.
                                 cron - Shortcut for crontab. It's basically focused on human-readable logs output.
                                 It's combination of --timestamp --profile --stdout-only --no-progress -vv.
                                 logstash - Logstash output format, for integration with ELK stack.
                                  [default: "text"]
      --cron                     Alias for --output-mode=cron. Deprecated!
  -h, --help                     Display help for the given command. When no command is given display help for the build command
  -q, --quiet                    Do not output any message
  -V, --version                  Display this application version
      --ansi|--no-ansi           Force (or disable --no-ansi) ANSI output
  -n, --no-interaction           Do not ask any interactive question
  -v|vv|vvv, --verbose           Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug

Examples

All examples are screenshots based on the package JBZoo/Toolbox.

Default output (no args) - minimal view

php ./vendor/bin/composer-graph

Example

Default output with PHP extensions (modules)

php ./vendor/bin/composer-graph  --show-ext

Example

Default output with versions of packages and relations

php ./vendor/bin/composer-graph  --show-link-versions  --show-package-versions

Example

Show suggested packages which are not installed

php ./vendor/bin/composer-graph  --show-suggests

Example

Show dev dependencies

php ./vendor/bin/composer-graph  --show-dev

Example

Full Report

All options are enabled but --show-php (too many packages).

php ./vendor/bin/composer-graph            \
                 --show-ext                \
                 --show-dev                \
                 --show-suggests           \
                 --show-link-versions      \
                 --show-package-versions

Example

Unit tests and check code style

make update
make test-all

License

MIT

See Also

  • CI-Report-Converter - Converting different error reports for deep compatibility with popular CI systems.
  • Composer-Diff - See what packages have changed after composer update.
  • Mermaid-PHP - Generate diagrams and flowcharts with the help of the mermaid script language.
  • Utils - Collection of useful PHP functions, mini-classes, and snippets for every day.
  • Image - Package provides object-oriented way to manipulate with images as simple as possible.
  • Data - Extended implementation of ArrayObject. Use files as config/array.
  • Retry - Tiny PHP library providing retry/backoff functionality with multiple backoff strategies and jitter support.
  • SimpleTypes - Converting any values and measures - money, weight, exchange rates, length, ...