Home

Awesome

Composer Diff Plugin

PHP 5.3+ | 7.x | 8.x Composer v1 | v2 Dependencies: 0 Latest version GitHub Workflow Status Codecov Mutation testing badge Downloads License

Generates packages changes report in Markdown format by comparing composer.lock files. Compares with last-committed changes by default.

Now available as GitHub Action!

preview

Installation

composer global require ion-bazan/composer-diff

Usage

composer diff # Displays packages changed in current git tree compared with HEAD
composer diff --help # Display detailed usage instructions

Example output

Prod PackagesOperationBaseTarget
psr/event-dispatcherNew-1.0.0
symfony/deprecation-contractsNew-v2.1.2
symfony/event-dispatcherUpgradedv2.8.52v5.1.2
symfony/event-dispatcher-contractsNew-v2.1.2
symfony/polyfill-php80New-v1.17.1
phpNew->=5.3
Dev PackagesOperationBaseTarget
phpunit/php-code-coverageDowngraded8.0.27.0.10
phpunit/php-file-iteratorDowngraded3.0.22.0.2
phpunit/php-text-templateDowngraded2.0.11.2.1
phpunit/php-timerDowngraded5.0.02.1.2
phpunit/php-token-streamDowngraded4.0.23.1.1
phpunit/phpunitDowngraded9.2.58.5.8
sebastian/code-unit-reverse-lookupDowngraded2.0.11.0.1
sebastian/comparatorDowngraded4.0.23.0.2
sebastian/diffDowngraded4.0.13.0.2
sebastian/environmentDowngraded5.1.14.2.3
sebastian/exporterDowngraded4.0.13.1.2
sebastian/global-stateDowngraded4.0.03.0.0
sebastian/object-enumeratorDowngraded4.0.13.0.3
sebastian/object-reflectorDowngraded2.0.11.1.1
sebastian/recursion-contextDowngraded4.0.13.0.0
sebastian/resource-operationsDowngraded3.0.12.0.1
sebastian/typeDowngraded2.1.01.1.3
sebastian/versionDowngraded3.0.02.0.1
phpunit/php-invokerRemoved3.0.1-
sebastian/code-unitRemoved1.0.3-

Options

Advanced usage

composer diff master # Compare current composer.lock with the one on master branch
composer diff master:composer.lock develop:composer.lock -p # Compare master and develop branches, including platform dependencies
composer diff --no-dev # ignore dev dependencies
composer diff -p # include platform dependencies
composer diff -f json # Output as JSON instead of table

You can find more documentation in the docs directory.

Strict mode

To help you control your dependencies, you may pass --strict option when running in CI. If there are any changes detected, a non-zero exit code will be returned.

Exit code of the command is built using following bit flags:

You may check for individual flags or simply check if the status is greater or equal 8 if you don't want to downgrade any package.

Contributing

Composer Diff is an open source project that welcomes pull requests and issues from anyone. Before opening pull requests, please consider reading our short Contribution Guidelines.

Similar packages

While there are several existing packages offering similar functionality:

This package offers: