9

My problem is when I want to run command : composer require laravel/ui --dev i get an error with title : [InvalidArgumentException] and error message is :

Package laravel/ui at version has a PHP requirement incompatible with your PHP version (5.6.40)

require [--dev] [--prefer-source] [--prefer-dist] [--no-progress] [--no-suggest] [--no-update] [--no-scripts] [--update-no-dev] [--update-with-dependencies] [--update-with-all-dependencies] [--ignore-platform-reqs] [--prefer-stable] [--prefer-lowest] [--sort-packages] [-o|--optimize-autoloader] [-a|--classmap-authoritative] [--apcu-autoloader] [--] []...`

NOTE : My PHP Version is : 7.4.3

Sehdev
  • 5,486
  • 3
  • 11
  • 34
Matin Rezaii
  • 136
  • 1
  • 1
  • 7

4 Answers4

26

It seems that the composer is using an old PHP version on your system, try to reconfigure it using this command:

composer config platform.php 7.4.3
Hafez Divandari
  • 8,381
  • 4
  • 46
  • 63
14

I had this error with some other package installations on my local version (my local php version differed from the one on server) so I just ran:

composer require "some/other-package:^1.0" --ignore-platform-reqs

and all is fine now.

Mehrdad Dehghani
  • 597
  • 7
  • 20
  • 1
    Never ignore platform requirements unless you really know what you are doing. Platform constraints are there for a reason. This is not a fix. It’s a workaround with possible side effects of the required library not working properly. You are supposed to fix your environment - not to suppress errors. – Mike Doe Dec 05 '21 at 08:36
  • 1
    @emix sure! you are right. this was for the time I didn't use docker for my deployment and environment settings and didn't want to change my local settings. If someone uses this, they must make sure all will be fine on their main deployment. – Mehrdad Dehghani Dec 05 '21 at 08:53
1

This error comes due to compatible version in your composer.json file. To permanently fix this issue, change the composer.json file "platform" configuration:

"platform": {
            "php": "7.4.3"
 }

Then execute composer install

Sehdev
  • 5,486
  • 3
  • 11
  • 34
1

2021 Dec

if being supposed to install "laravel/ui" naturally it would claim for matching php version because current ui level is 3.3.0 and php's is 8.0.2 (or so, not sure). Thus what you re going to console next is:

composer update      //in case you corrupted something 
composer require laravel/ui:^3.3.0
CodeToLife
  • 3,672
  • 2
  • 41
  • 29