PHPackages                             jbzoo/composer-diff - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. jbzoo/composer-diff

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

jbzoo/composer-diff
===================

See what has changed after a composer update.

7.1.0(9mo ago)54911.3k↓60.3%61MITPHPPHP ^8.2CI passing

Since Jul 14Pushed 9mo ago2 watchersCompare

[ Source](https://github.com/JBZoo/Composer-Diff)[ Packagist](https://packagist.org/packages/jbzoo/composer-diff)[ RSS](/packages/jbzoo-composer-diff/feed)WikiDiscussions master Synced 3d ago

READMEChangelog (10)Dependencies (9)Versions (22)Used By (1)

JBZoo / Composer-Diff
=====================

[](#jbzoo--composer-diff)

[![CI](https://github.com/JBZoo/Composer-Diff/actions/workflows/main.yml/badge.svg?branch=master)](https://github.com/JBZoo/Composer-Diff/actions/workflows/main.yml?query=branch%3Amaster)[![Coverage Status](https://camo.githubusercontent.com/c01fe3061b85b6049f4539db1efa52c5d5250f01e270d44fec2d049010bb79b9/68747470733a2f2f636f766572616c6c732e696f2f7265706f732f6769746875622f4a425a6f6f2f436f6d706f7365722d446966662f62616467652e7376673f6272616e63683d6d6173746572)](https://coveralls.io/github/JBZoo/Composer-Diff?branch=master)[![Psalm Coverage](https://camo.githubusercontent.com/f5089452653146f445e9cd4f7f3f5aa85fb813b27b29658ebffe225c061582b2/68747470733a2f2f73686570686572642e6465762f6769746875622f4a425a6f6f2f436f6d706f7365722d446966662f636f7665726167652e737667)](https://shepherd.dev/github/JBZoo/Composer-Diff)[![Psalm Level](https://camo.githubusercontent.com/f8ac99d1156439e623d53f12a50942a2d1feb55504af390790429ea810c6a03a/68747470733a2f2f73686570686572642e6465762f6769746875622f4a425a6f6f2f436f6d706f7365722d446966662f6c6576656c2e737667)](https://shepherd.dev/github/JBZoo/Composer-Diff)[![CodeFactor](https://camo.githubusercontent.com/a707b35b4e41ab72e004c22bfcdecdff6561f3608c001f8f5e17c51fd8b843f0/68747470733a2f2f7777772e636f6465666163746f722e696f2f7265706f7369746f72792f6769746875622f6a627a6f6f2f636f6d706f7365722d646966662f6261646765)](https://www.codefactor.io/repository/github/jbzoo/composer-diff/issues)

[![Stable Version](https://camo.githubusercontent.com/3ae4ac54fd0873e3871c0a093299c7bc866fbb9a39e52bf7b6fdf5409eaedc56/68747470733a2f2f706f7365722e707567782e6f72672f6a627a6f6f2f636f6d706f7365722d646966662f76657273696f6e)](https://packagist.org/packages/jbzoo/composer-diff/)[![Total Downloads](https://camo.githubusercontent.com/da4bf8cba0d587dc200e16aaf450025362852cfcba5bd070ebac6e8e66b3d704/68747470733a2f2f706f7365722e707567782e6f72672f6a627a6f6f2f636f6d706f7365722d646966662f646f776e6c6f616473)](https://packagist.org/packages/jbzoo/composer-diff/stats)[![Dependents](https://camo.githubusercontent.com/6da516149259ca0759daa1b8882a10472aabbecc1bec5873b313f839b3a69f7b/68747470733a2f2f706f7365722e707567782e6f72672f6a627a6f6f2f636f6d706f7365722d646966662f646570656e64656e7473)](https://packagist.org/packages/jbzoo/composer-diff/dependents?order_by=downloads)[![GitHub License](https://camo.githubusercontent.com/3df716b4a90f95e59f31a8e666edd467ff0f0dd4b54c9494aafcbbbdcd14d040/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f6a627a6f6f2f636f6d706f7365722d64696666)](https://github.com/JBZoo/Composer-Diff/blob/master/LICENSE)

A powerful CLI tool for visualizing changes in Composer dependencies after running `composer update`. Compare two `composer.lock` files and see exactly what packages were added, removed, upgraded, or downgraded with beautiful output formatting and direct links to changelogs.

Table of Contents
-----------------

[](#table-of-contents)

- [Features](#features)
- [Installation](#installation)
    - [Via Composer (Recommended)](#via-composer-recommended)
    - [Standalone PHAR](#standalone-phar)
- [Basic Usage](#basic-usage)
- [Help Description](#help-description)
- [Output Examples](#output-examples)
    - [Default view (--output=console)](#default-view---outputconsole)
    - [Markdown Output (--output=markdown)](#markdown-output---outputmarkdown)
    - [JSON Output (--output=json)](#json-output---outputjson)
- [Advanced Usage](#advanced-usage)
    - [Compare Specific Files](#compare-specific-files)
    - [Environment Filtering](#environment-filtering)
    - [Output Formatting](#output-formatting)
    - [Real-world Examples](#real-world-examples)
- [Requirements](#requirements)
- [Architecture](#architecture)
    - [Change Detection Logic](#change-detection-logic)
    - [Supported Git Platforms](#supported-git-platforms)
- [Development](#development)
    - [Setup](#setup)
    - [Testing](#testing)
    - [Building PHAR](#building-phar)
- [Roadmap](#roadmap)
- [License](#license)
- [See Also](#see-also)

Features
--------

[](#features)

- **Visual Dependency Tracking**: See exactly what changed after `composer update` with color-coded output
- **Multiple Output Formats**: Console tables, Markdown for PRs, or JSON for automation and CI/CD pipelines
- **Smart Version Detection**: Automatically detects upgrades, downgrades, new, removed, and changed packages
- **Direct Links to Changes**: Generates comparison URLs for GitHub, GitLab, and Bitbucket repositories
- **Environment Filtering**: Compare production (`require`) and development (`require-dev`) dependencies separately or together
- **Git Integration**: Compare current lock file with any git reference (HEAD, branches, tags)
- **Dev Package Support**: Handles dev branches with commit hash detection and comparison
- **CI/CD Friendly**: Perfect for automated workflows, deployment pipelines, and Pull Request automation
- **PHAR Distribution**: Standalone executable or Composer installation options

Installation
------------

[](#installation)

### Via Composer (Recommended)

[](#via-composer-recommended)

```
# Install for specific project
composer require jbzoo/composer-diff

# Install globally
composer global require jbzoo/composer-diff
```

### Standalone PHAR

[](#standalone-phar)

```
# Download latest release
wget https://github.com/JBZoo/Composer-Diff/releases/latest/download/composer-diff.phar

# Make it executable
chmod +x composer-diff.phar
```

Basic Usage
-----------

[](#basic-usage)

```
# Update your dependencies first
composer update

# Show what changed (compares HEAD:composer.lock with ./composer.lock)
composer-diff

# If installed locally in project
php ./vendor/bin/composer-diff

# If using PHAR file
php composer-diff.phar
```

Help Description
----------------

[](#help-description)

```
./vendor/bin/composer-diff --help

Description:
  Show difference between two versions of composer.lock files

Usage:
  diff [options]

Options:
      --source=SOURCE            The file, git ref, or git ref with filename to compare FROM [default: "HEAD:composer.lock"]
      --target=TARGET            The file, git ref, or git ref with filename to compare TO [default: "./composer.lock"]
      --env=ENV                  Show only selected environment. Available options: both, require, require-dev [default: "both"]
      --output=OUTPUT            Output format. Available options: console, markdown, json [default: "console"]
      --no-links                 Hide all links in tables
      --strict                   Return exit code if you have any difference
      --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 diff command
      --silent                   Do not output any message
  -q, --quiet                    Only errors are displayed. All other output is suppressed
  -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

```

Output Examples
---------------

[](#output-examples)

### Default view (--output=console)

[](#default-view---outputconsole)

```
PHP Production Dependencies (require)
+-------------------+------------+--------------------+---------------------+---------------------------------------------------------------+
| Package           | Action     |        Old Version |         New Version | Details                                                       |
+-------------------+------------+--------------------+---------------------+---------------------------------------------------------------+
| vendor/downgraded | Downgraded |              2.0.0 |               1.0.0 | https://gitlab.com/vendor/downgraded/compare/2.0.0...1.0.0    |
| vendor/new        | New        |                  - |               1.0.0 |                                                               |
| vendor/no-tag     | Changed    | dev-master@bbc0fba |  dev-master@f2f9280 | https://gitlab.com/vendor/package-1/compare/bbc0fba...f2f9280 |
| vendor/no-tag-new | New        |                  - | dev-develop@a999014 |                                                               |
| vendor/removed    | Removed    |              1.0.0 |                   - |                                                               |
| vendor/upgraded   | Upgraded   |              1.0.0 |               2.0.0 | https://gitlab.com/vendor/upgraded/compare/1.0.0...2.0.0      |
+-------------------+------------+--------------------+---------------------+---------------------------------------------------------------+

```

Rendered in your terminal: [![Dummy example](https://raw.githubusercontent.com/JBZoo/Composer-Diff/master/resources/dummy.png)](https://raw.githubusercontent.com/JBZoo/Composer-Diff/master/resources/dummy.png)

Also, see [colored example in travis-ci](https://travis-ci.org/github/JBZoo/Composer-Diff/jobs/705031632#L414)[![Real project](https://raw.githubusercontent.com/JBZoo/Composer-Diff/master/resources/drupal.png)](https://raw.githubusercontent.com/JBZoo/Composer-Diff/master/resources/drupal.png)

### Markdown Output (--output=markdown)

[](#markdown-output---outputmarkdown)

Source code:

```
## PHP Production Dependencies (require)

| Package                                                    | Action     |        Old Version |         New Version |                                                                              |
|:-----------------------------------------------------------|:-----------|-------------------:|--------------------:|:-----------------------------------------------------------------------------|
| [vendor/downgraded](https://gitlab.com/vendor/downgraded)  | Downgraded |              2.0.0 |               1.0.0 | [See details](https://gitlab.com/vendor/downgraded/compare/2.0.0...1.0.0)    |
| [vendor/new](https://gitlab.com/vendor/new)                | New        |                  - |               1.0.0 |                                                                              |
| [vendor/no-tag](https://gitlab.com/vendor/package-1)       | Changed    | dev-master@bbc0fba |  dev-master@f2f9280 | [See details](https://gitlab.com/vendor/package-1/compare/bbc0fba...f2f9280) |
| [vendor/no-tag-new](https://gitlab.com/vendor-1/package-1) | New        |                  - | dev-develop@a999014 |                                                                              |
| [vendor/removed](https://gitlab.com/vendor/removed)        | Removed    |              1.0.0 |                   - |                                                                              |
| [vendor/upgraded](https://gitlab.com/vendor/upgraded)      | Upgraded   |              1.0.0 |               2.0.0 | [See details](https://gitlab.com/vendor/upgraded/compare/1.0.0...2.0.0)      |
```

Rendered in your readme or PR/MR description:

PackageActionOld VersionNew Version[vendor/downgraded](https://gitlab.com/vendor/downgraded)Downgraded2.0.01.0.0[See details](https://gitlab.com/vendor/downgraded/compare/2.0.0...1.0.0)[vendor/new](https://gitlab.com/vendor/new)New-1.0.0[vendor/no-tag](https://gitlab.com/vendor/package-1)Changeddev-master@bbc0fbadev-master@f2f9280[See details](https://gitlab.com/vendor/package-1/compare/bbc0fba...f2f9280)[vendor/no-tag-new](https://gitlab.com/vendor-1/package-1)New-dev-develop@a999014[vendor/removed](https://gitlab.com/vendor/removed)Removed1.0.0-[vendor/upgraded](https://gitlab.com/vendor/upgraded)Upgraded1.0.02.0.0[See details](https://gitlab.com/vendor/upgraded/compare/1.0.0...2.0.0)### JSON Output (--output=json)

[](#json-output---outputjson)

```
{
    "require": {
        "vendor\/downgraded": {
            "name": "vendor\/downgraded",
            "url": "https:\/\/gitlab.com\/vendor\/downgraded",
            "version_from": "2.0.0",
            "version_to": "1.0.0",
            "mode": "Downgraded",
            "compare": "https:\/\/gitlab.com\/vendor\/downgraded\/compare\/2.0.0...1.0.0"
        },
        "vendor\/new": {
            "name": "vendor\/new",
            "url": "https:\/\/gitlab.com\/vendor\/new",
            "version_from": null,
            "version_to": "1.0.0",
            "mode": "New",
            "compare": null
        },
        "vendor\/no-tag": {
            "name": "vendor\/no-tag",
            "url": "https:\/\/gitlab.com\/vendor\/package-1",
            "version_from": "dev-master@bbc0fba",
            "version_to": "dev-master@f2f9280",
            "mode": "Changed",
            "compare": "https:\/\/gitlab.com\/vendor\/package-1\/compare\/bbc0fba...f2f9280"
        },
        "vendor\/no-tag-new": {
            "name": "vendor\/no-tag-new",
            "url": "https:\/\/gitlab.com\/vendor-1\/package-1",
            "version_from": null,
            "version_to": "dev-develop@a999014",
            "mode": "New",
            "compare": null
        },
        "vendor\/removed": {
            "name": "vendor\/removed",
            "url": "https:\/\/gitlab.com\/vendor\/removed",
            "version_from": "1.0.0",
            "version_to": null,
            "mode": "Removed",
            "compare": null
        },
        "vendor\/upgraded": {
            "name": "vendor\/upgraded",
            "url": "https:\/\/gitlab.com\/vendor\/upgraded",
            "version_from": "1.0.0",
            "version_to": "2.0.0",
            "mode": "Upgraded",
            "compare": "https:\/\/gitlab.com\/vendor\/upgraded\/compare\/1.0.0...2.0.0"
        }
    }
}
```

Advanced Usage
--------------

[](#advanced-usage)

### Compare Specific Files

[](#compare-specific-files)

```
# Compare two specific composer.lock files
composer-diff --source="old/composer.lock" --target="new/composer.lock"

# Compare Git references
composer-diff --source="HEAD~1:composer.lock" --target="HEAD:composer.lock"

# Compare with specific branch or tag
composer-diff --source="v1.0.0:composer.lock" --target="./composer.lock"
```

### Environment Filtering

[](#environment-filtering)

```
# Production dependencies only
composer-diff --env=require

# Development dependencies only
composer-diff --env=require-dev

# Both environments (default)
composer-diff --env=both
```

### Output Formatting

[](#output-formatting)

```
# Markdown output for Pull Requests
composer-diff --output=markdown

# JSON output for automation
composer-diff --output=json

# Hide comparison links
composer-diff --no-links

# Strict mode (exit code 1 if differences found)
composer-diff --strict
```

### Real-world Examples

[](#real-world-examples)

```
# Generate PR description after update
composer update
composer-diff --output=markdown >> pr-description.md

# CI/CD pipeline check
composer-diff --strict --output=json > changes.json

# Compare major version upgrades
composer-diff --source="tags/v1.0:composer.lock" --target="tags/v2.0:composer.lock"
```

Requirements
------------

[](#requirements)

- **PHP**: ^8.2
- **Extensions**: ext-json, ext-filter
- **Composer**: ^2.0 (for development)

Architecture
------------

[](#architecture)

The tool is built with a clean, object-oriented architecture:

- **`DiffAction`**: Main CLI command handler (Symfony Console)
- **`Comparator`**: Orchestrates comparison between composer.lock files
- **`ComposerLock`**: Parses and manages composer.lock data
- **`Package`**: Represents individual packages with version handling
- **`Diff`**: Compares package versions and determines change types
- **`Url`**: Generates comparison URLs for Git hosting platforms
- **Renderers**: Multiple output formats (Console, Markdown, JSON)

### Change Detection Logic

[](#change-detection-logic)

The tool intelligently categorizes changes:

- **New**: Package added to dependencies
- **Removed**: Package removed from dependencies
- **Upgraded**: Semantic version increased (1.0.0 → 2.0.0)
- **Downgraded**: Semantic version decreased (2.0.0 → 1.0.0)
- **Changed**: Dev branches with different commit hashes
- **Same**: No changes (filtered out by default)

### Supported Git Platforms

[](#supported-git-platforms)

Automatically generates comparison URLs for:

- **GitHub**: `github.com/user/repo/compare/v1.0.0...v2.0.0`
- **GitLab**: `gitlab.com/user/repo/compare/v1.0.0...v2.0.0`
- **Bitbucket**: `bitbucket.org/user/repo/branches/compare/v1.0.0%0Dv2.0.0`

Development
-----------

[](#development)

### Setup

[](#setup)

```
# Clone and install dependencies
git clone https://github.com/JBZoo/Composer-Diff.git
cd Composer-Diff
make build
```

### Testing

[](#testing)

```
# Run all tests
make test-all

# Run specific test suites
make test          # PHPUnit tests
make test-drupal   # Real Drupal upgrade test
make test-manual   # Manual output examples
make codestyle     # Code quality checks
```

### Building PHAR

[](#building-phar)

```
# Build standalone PHAR executable
make build-phar

# Create symlink for local testing
make create-symlink
```

Roadmap
-------

[](#roadmap)

- Supporting Drupal repos. [For example](https://git.drupalcode.org/project/fast_404).
- Add action in the composer via API like `composer lock-diff`.
- Fixes [the same issue](https://github.com/davidrjonas/composer-lock-diff/issues/26) with complex/custom name of tag.
- Auto-detecting alias name of branch.
- No warp links for Markdown format.
- (?) Support MS Windows...

Unit tests and check code style
-------------------------------

[](#unit-tests-and-check-code-style)

```
make build
make test-all
```

License
-------

[](#license)

MIT

See Also
--------

[](#see-also)

- [CI-Report-Converter](https://github.com/JBZoo/CI-Report-Converter) - Converting different error reports for deep compatibility with popular CI systems.
- [Composer-Graph](https://github.com/JBZoo/Composer-Graph) - Dependency graph visualization of composer.json based on mermaid-js.
- [Mermaid-PHP](https://github.com/JBZoo/Mermaid-PHP) - Generate diagrams and flowcharts with the help of the mermaid script language.
- [Utils](https://github.com/JBZoo/Utils) - Collection of useful PHP functions, mini-classes, and snippets for every day.
- [Image](https://github.com/JBZoo/Image) - Package provides object-oriented way to manipulate with images as simple as possible.
- [Data](https://github.com/JBZoo/Data) - Extended implementation of ArrayObject. Use files as config/array.
- [Retry](https://github.com/JBZoo/Retry) - Tiny PHP library providing retry/backoff functionality with multiple backoff strategies and jitter support.
- [SimpleTypes](https://github.com/JBZoo/SimpleTypes) - Converting any values and measures - money, weight, exchange rates, length, ...

Special thanks to the project [davidrjonas/composer-lock-diff](https://github.com/davidrjonas/composer-lock-diff) which inspired me to make a great utility :)

###  Health Score

55

—

FairBetter than 97% of packages

Maintenance58

Moderate activity, may be stable

Popularity50

Moderate usage in the ecosystem

Community19

Small or concentrated contributor base

Maturity77

Established project with proven stability

 Bus Factor1

Top contributor holds 89.3% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~105 days

Recently: every ~203 days

Total

19

Last Release

278d ago

Major Versions

1.8.1 → 7.0.02023-07-09

PHP version history (5 changes)1.0.0PHP &gt;=7.2

1.1.0PHP ^7.2

1.8.0PHP &gt;=7.4

7.0.0PHP ^8.1

7.1.0PHP ^8.2

### Community

Maintainers

![](https://www.gravatar.com/avatar/75e6de2785f6d099699f430ff58404af4fc0e83060d2953028c9664a54704a5f?d=identicon)[smetdenis](/maintainers/smetdenis)

---

Top Contributors

[![SmetDenis](https://avatars.githubusercontent.com/u/1118678?v=4)](https://github.com/SmetDenis "SmetDenis (50 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (2 commits)")[![llaville](https://avatars.githubusercontent.com/u/364342?v=4)](https://github.com/llaville "llaville (2 commits)")[![andrew-demb](https://avatars.githubusercontent.com/u/12499813?v=4)](https://github.com/andrew-demb "andrew-demb (1 commits)")[![jahidulpabelislam](https://avatars.githubusercontent.com/u/15434150?v=4)](https://github.com/jahidulpabelislam "jahidulpabelislam (1 commits)")

---

Tags

composercomposer-diffcomposer-jsoncomposer-lockcomposer-lock-diffcomposer-packagesjbzoojsonphpphpcomposerdiffcomposer.lockcomposer.jsoncomposer diff

### Embed Badge

![Health badge](/badges/jbzoo-composer-diff/health.svg)

```
[![Health](https://phpackages.com/badges/jbzoo-composer-diff/health.svg)](https://phpackages.com/packages/jbzoo-composer-diff)
```

###  Alternatives

[matomo/matomo

Matomo is the leading Free/Libre open analytics platform

21.7k38.9k](/packages/matomo-matomo)[composer/composer

Composer helps you declare, manage and install dependencies of PHP projects. It ensures you have the right stack everywhere.

29.5k196.2M3.1k](/packages/composer-composer)[friendsofphp/php-cs-fixer

A tool to automatically fix PHP code style

13.5k251.2M25.2k](/packages/friendsofphp-php-cs-fixer)[drupal/core

Drupal is an open source content management platform powering millions of websites and applications.

21866.0M1.7k](/packages/drupal-core)[drupal/core-recommended

Locked core dependencies; require this project INSTEAD OF drupal/core.

6942.5M421](/packages/drupal-core-recommended)[kimai/kimai

Kimai - Time Tracking

4.8k9.0k1](/packages/kimai-kimai)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
