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
What's New and Changed in phpMyAdmin 5.2

What's New and Changed in phpMyAdmin 5.2

An introduction to front-end and back-end changes and improvements in phpMyAdmin version 5.2.
Install/Upgrade PHP 8.1 on Ubuntu/Debian

Install/Upgrade PHP 8.1 on Ubuntu/Debian

A comprehensive guide on how to install or upgrade to PHP 8.1 on Ubuntu/Debian based systems.
PHP 8.1 Is Released!

PHP 8.1 Is Released!

Over 120 people helped shape PHP 8.1! Here are some posters to celebrate our loud!
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.