How to install Composer packages ignoring PHP version requirements

Published On2020-06-03

A new feature in Composer v2 allows you to selectively ignore platform requirements.

composer install --ignore-platform-req=php

Compared to --ignore-platform-reqs

Composer already has a --ignore-platform-reqs option (notice the s in reqs), but it ignores all platform requirements, including PHP version, extensions (ext-*), and composer-plugin-api.

The new --ignore-platform-req option can be used to set specific requirements that Composer can ignore.

Ignore multiple platform requirements

You can specify one or more platform requirements to ignore by simply using the option multiple times.

For example, to ignore the PHP version and ext-zip, but enforce all other platform requirements, you can use the command like this:

composer install --ignore-platform-req=php --ignore-platform-req=ext-zip

Install Composer packages on unreleased PHP versions

A common use-case of ignore-platform-req option would be to test PHP packages in unreleased PHP versions, or dev builds of PHP.

Libraries such as PHPUnit come with rather strict PHP version constraint in their composer.json file, which prevents them the libraries from being installed in dev versions of PHP.

Instead of using ignore-platform-reqs, which would ignore all platform requirements such as extensions (which might be required for the package to function), you can use ignore-platform-req option to selectively specify platform requirements you intentionally ignore.

Recent Articles on PHP.Watch

All ArticlesFeed 
All the Easter Eggs in PHP

All the Easter Eggs in PHP

A trip down the memory with PHP's Easter Eggs over the years
Laragon: Simple, Flexible, and Modern Development Server Environment for Windows

Laragon: Simple, Flexible, and Modern Development Server Environment for Windows

Laragon is a modern, simple, and flexible Windows Development Environment that provides support for multiple PHP, Apache, and MySQL versions, with quick HTTPS setup, Quick-app templates, Composer, npm, and more
Testing Randomness of PHP Random Number Functions

Testing Randomness of PHP Random Number Functions

Visualizing and testing various Random Number Generators available in PHP.
Subscribe to PHP.Watch newsletter for monthly updates

You will receive an email on last Wednesday of every month and on major PHP releases with new articles related to PHP, upcoming changes, new features and what's changing in the language. No marketing emails, no selling of your contacts, no click-tracking, and one-click instant unsubscribe from any email you receive.