Get "PHP 8 in a Nuthshell" (Soon includes PHP 8.4)
Amit Merchant

Amit Merchant

A blog on PHP, JavaScript, and more

Dry running Composer update without actually updating dependencies

It would always be a good idea to cross-verify/confirm a destructive action before you actually perform it. For instance, while giving users the ability to delete something important, let’s say the user account, it’s a good idea to present them a confirmation popup before he/she deletes the account permanently.

Similarly, the composer update is one such action. While it’s not so destructive to update the dependencies, it’s always good to have the ability to check what would get updated when you run the command because, in some situations, you might not want to update some of the dependencies.

And that’s when this handy option called --dry-run in Composer comes to the rescue.

The --dry-run option

Thanks to this tweet by Povilas Korop, today I got to know about this --dry-run option, which when run along with the composer update command, will simulate the command without actually updating the dependencies.

$ composer update --dry-run

When run, you will see all the dependencies being updated just like you would see when you run the composer update command. The only difference is it’s just a visual cue of which package will get updated to which version without the actual dependency updation.

Here’s how it would look like.

Dry running composer update

As you can tell, it looks exactly like how you would see when composer update is run. But under the hood, nothing has been updated.

Apart from this, you can also use the --dry-run option with composer install to dry running installation of Composer dependencies!

Like this article?

Buy me a coffee

👋 Hi there! I'm Amit. I write articles about all things web development. You can become a sponsor on my blog to help me continue my writing journey and get your brand in front of thousands of eyes.

Comments?