azngunit81
azngunit81

Reputation: 1604

Composer is not recognizing PHP 7

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

Upvotes: 7

Views: 30403

Answers (4)

D.Y.F
D.Y.F

Reputation: 1

change php default V

sudo update-alternatives --config php

Upvotes: 0

localheinz
localheinz

Reputation: 9582

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.

Upvotes: 16

baoniu
baoniu

Reputation: 483

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
    }
},

Upvotes: 4

Sven
Sven

Reputation: 70853

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.

Upvotes: 5

Related Questions