Check which Composer dependencies requires PHP 8 or 8.1
Oftentimes, you may find it useful to check whether which among all the packages requires/depends upon a certain PHP version.
For instance, Povilas Korop recently faced an issue where he wasn’t able to spin up a newly created Laravel project because of PHP compatibility issues with certain packages. So, he essentially wanted to check what packages depend upon PHP 8.1.
Willem Oostendorp then suggested a nice little Composer command that lets you do just that.
So, if we want to check which packages depend upon PHP 8.1, here’s how we can check it.
$ composer depends php | grep 8.1
As you can tell, we are using Composer’s depends command to first find out the packages that depend upon php
and then pass that result to grep
to further filter to show only packages that require PHP 8.1 specifically.
Here’s how the result would look like when you run this command
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.