π How to see what changed in Composer files

Search for a command to run...

No comments yet. Be the first to comment.
If youβre like many developers, you know the frustration of being stuck on an older PHP version. Upgrading to the latest and greatest can be a daunting task, especially when you're dealing with legacy code and tight deadlines π€¬. But fear not! Symfon...
Flag emojis are a fun and visual way to represent countries and regions. These emojis are part of the Unicode standard and are created using a pair of regional indicator symbols. In this article, we will explore how to convert 2-letter ISO 3166-1 cou...

If youβre like many developers, you know the frustration of being stuck on an older PHP version. Upgrading to the latest and greatest can be a daunting task, especially when you're dealing with legacy code and tight deadlines π€¬. But fear not! Symfon...

Have you ever wished some queued jobs would be processed way ahead others? For example, if you want your VIP client's transanctions to be completed before everyone else's, this article might help you. Simple approach β¨ If you have only a few tiers of...

As a part of your digital identity, you may want to use a custom domain for your personal email address. In this article I'll show you how to easily set up email receiving and sending without breaking a bank. Why do I need a custom email domain in th...

When reviewing a Pull Request that touched composer.json and composer.lock files you might notice that the diffs are usually pretty huge and it's almost impossible to tell what exactly happened there - which packages got added, updated, downgraded or removed? Nobody knows.
That's because Composer stores information about all packages that should be installed in composer.lock together with some of their metadata. This helps to manage the dependencies efficiently and browse most information offline but there is currently no built-in way to compare these files when changed.
Don't worry, I got you. Simply install Composer-Diff plugin which allows you to easily compare any two versions of your composer.lock files:
composer global req ion-bazan/composer-diff
To run it in your repository:
composer diff # Displays packages changed in current git tree compared with HEAD
composer diff --help # Display detailed usage instructions
By default, it compares current filesystem version with your last committed changes (to use it locally just before committing your new changes):

It produces a colourful, tabulated markdown output which can be copy-pasted into your PR description for reference π€©
Besides of generating diff for your current filesystem changes, you can compare any 2 git refs or local copies of files using --base and --target options or arguments:
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
Did I mention it works with all PHP versions from 5.3 all the way till 8.4+?
Me too! That's why I made things even easier with GitHub Actions - I'm adding Composer Diff Action to all my projects to enjoy an automated report in every PR.

Another day, another useful automation.
No problem, you can check out a few other tools instead: