How to install Composer packages ignoring PHP version requirements

Published On03 Jun 2020

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 
How to fix PHP Curl HTTPS Certificate Authority issues on Windows

How to fix PHP Curl HTTPS Certificate Authority issues on Windows

On Windows, HTTPS requests made with the Curl extension can fail because Curl has no root certificate list to validate the server certificates. This article discusses the secure and effective solutions, and highlights bad advice that can leave PHP applications insecure.
AEGIS Encryption with PHP Sodium Extension

AEGIS Encryption with PHP Sodium Extension

The Sodium extension in PHP 8.4 now supports AEGIS-128L and AEGIS256 Authenticated Encryption ciphers. They are significantly faster than AES-GCM and CHACHA20-POLY1305. This article benchmarks them and explains how to securely encrypt and decrypt data using AEGIS-128L and AEGIS256 on PHP.
How to Install/Upgrade PHP 8.3 on MacOS with Homebrew

How to Install/Upgrade PHP 8.3 on MacOS with Homebrew

Install PHP 8.3 and PHP extensions on MacOS with Homebrew.
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.