Home » Php » Composer is not recognizing PHP 7

Composer is not recognizing PHP 7

Posted by: admin July 12, 2020 Leave a comment


I created a travis profile to test my project from PHP 5.6 to PHP 7.

I am getting the following error when composer is run:

Your requirements could not be resolved to an installable set of packages.
  Problem 1
    - This package requires php ~5.4 but your PHP version (7.0.1-dev) does not satisfy that requirement.

the command that I am running is:

composer update -n

with travis set to environment PHP 5.6 I do not run into this issue

How to&Answers:

A package that you use, or your own software itself, explicitly requires a PHP 5.x version (~5.4), with x being at least 4, or higher (i.e. it would run with PHP 5.5, 5.6, or even 5.10 if it would exist).

This package does not allow PHP 7. That’s why you cannot run composer update successfully.


If the platform requirement is in your root package, you can solve it by amending composer.json as such

    "require": {
        "php": "~5.4 | ^7.0"

You could also try to ignore platform requirements, but depends on whether you actually want to see that happen:

$ composer install --ignore-platform-reqs

For reference, see https://getcomposer.org/doc/03-cli.md#install.


check your composer.json file,
delete this code:

 "config": {
    "bin-dir": "bin",
    "platform": {
        "php": "5.x.1"  // Or change 5.x.1 to your php version


change php default V

sudo update-alternatives --config php