Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

like image 837
azngunit81 Avatar asked Dec 08 '15 00:12

azngunit81


People also ask

Why is my composer not working?

Make sure you have no problems with your setup by running the installer's checks via curl -sS https://getcomposer.org/installer | php -- --check . Try clearing Composer's cache by running composer clear-cache . Ensure you're installing vendors straight from your composer.

How do you solve a composer error?

To solve the Memory exhausted issue, you can try running composer with an Unlimited memory flag like this: php -d memory_limit=-1 /usr/local/bin/composer [COMMAND] or php -d memory_limit=-1 composer. phar [COMMAND] when using a local composer. If that doesn't help, you can upgrade your hosting plan.

How do I know if PHP composer is installed?

You can check your installed composer version using a command composer -v at the current path. Such as: composer -v.


2 Answers

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.

like image 121
localheinz Avatar answered Sep 18 '22 21:09

localheinz


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.

like image 35
Sven Avatar answered Sep 19 '22 21:09

Sven