Get "PHP 8 in a Nuthshell" (Now comes with PHP 8.3)
Amit Merchant

Amit Merchant

A blog on PHP, JavaScript, and more

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

composer depends with grep

Learn the fundamentals of PHP 8 (including 8.1, 8.2, and 8.3), the latest version of PHP, and how to use it today with my new book PHP 8 in a Nutshell. It's a no-fluff and easy-to-digest guide to the latest features and nitty-gritty details of PHP 8. So, if you're looking for a quick and easy way to PHP 8, this is the book for you.

Like this article? Consider leaving a

Tip

👋 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?