176

When I run composer update I receive some wired output.

enter image description here

Here is my composer.json look like.

{ "name": "laravel/laravel", "description": "The Laravel Framework.", "keywords": ["framework", "laravel"], "license": "MIT", "repositories": [{ "type": "vcs", "url": "https://github.com/Zizaco/ardent.git" }], "require-dev": { "phpunit/phpunit": "4.3.*" }, "require": { "laravel/framework": "4.2.*", "laravelbook/ardent": "dev-master as 2.4.0", "zizaco/entrust": "dev-master", "sebklaus/profiler": "dev-master", "doctrine/dbal": "dev-master" }, "autoload": { "classmap": [ "app/commands", "app/controllers", "app/models", "app/database/migrations", "app/database/seeds", "app/tests", "app/libraries" ] }, "scripts": { "post-install-cmd": [ "php artisan clear-compiled", "php artisan optimize" ], "post-update-cmd": [ "php artisan clear-compiled", "php artisan optimize" ], "post-create-project-cmd": [ "php artisan key:generate" ] }, "config": { "preferred-install": "dist" }, "minimum-stability": "stable" } 

How do I fix that ?

1
  • 2
    Please share more details, like the error message in text form, along with your attempts to resolve the problem Commented Nov 16, 2023 at 10:52

15 Answers 15

336

Run this command:

composer install --ignore-platform-reqs 

or

composer update --ignore-platform-reqs 

Composer ignore-platform-reqs flag explanation

Sign up to request clarification or add additional context in comments.

5 Comments

Any disadvantage of using this?
@AdemTepe, please this hannesvdvreken.com/2015/01/18/…
This needs an explanation
These commands will install and update all the packages regardless of the version conflicts.
This is both stupid and dangerous. The requirements are there for a reason, and a package forced to be installed may appear to run correctly at first, before breaking in unexpected ways.
65

Your software dependencies have an incompatible version conflict.

At the same time you want to install any Laravel 4.2.x version, and "zizaco/entrust" from its master branch. And that master branch requires at least Laravel 5.0 (roughly speaking).

The problem comes from the dependency on branches. It's likely that the package zizaco/entrust once was using Laravel 4.2 in its master branch, and that you were able to install your dependencies at that day. But the very moment this branch gets updated with an incompatible version requirement, you will never ever be able to run composer update and get updated dependencies.

Always use tagged versions! Ideally you use a relaxed version requirement that allows for compatible updates. This should be expressed as a tilde-two-number version requirement: ~1.2 would install a version 1.2.0 and up (like 1.2.99 or 1.2.100), and also 1.3 and up. If you need a certain patch release: Caret-three-number version ^1.2.10 will install 1.2.10 or up, also 1.3 and up.

Using this version requirement instead of dev-master will allow you to use released versions instead of the unstable state in the master branch, and allows you to address the most recent version that still works with Laravel 4.2. I guess that would be zizaco/entrust version 1.3.0, but version 1.2 would also qualify. Go with "zizaco/entrust": "~1.2".

2 Comments

It would be helpful to know what part of the error message made you think that Laravel 5.0 was required by zizaco/entrust.
Well, if I remember correctly I was looking at the mentioned library and saw the requirements in it's composer.json. And I probably paraphrased what I saw because there was no explicit requirement, but some components of it. In the error message, you see that illuminate/support ^5.0 is required by zizaco/entrust, and if you know that "Laravel" and "Illuminate" are basically the same thing, the conclusion should be correct.
45

I faced the same issue using the 'Lumen' microservice framework. I recently resolved the same issue by installing two packages:-

  1. sudo apt-get install php7.0-mbstring
  2. sudo apt-get install php7.0-xml or sudo apt-get install php-xml

After installing this, you need to execute this command: composer update

4 Comments

People should never use composer update in production, this may cause problems. composer install is the right command to install. I downvoted you but I'm upvoting because 1 and 2 are correct.
In my situation installing php-gd did the trick. Composer didn't mention this anywhere in the failure output even with the verbose (-vvv) flag on.
I'm working on Ubuntu 20.04. Only running this command was sufficient: sudo apt-get install php-xml
You may want to install curl as well sudo apt-get install php-curl
26

The simplest solution is adding --ignore-platform-reqs flag.

If you are running composer install or composer update use it with --ignore-platform-reqs flag

Example

composer install --ignore-platform-reqs 

Or

composer update --ignore-platform-reqs 

And this should do the trick!

Comments

17

I use Windows 10 machine working with PHP 8 and Lavarel 8 and I got the same error, I used the following command :-

composer update --ignore-platform-reqs

to update all the packages regardless of the version conflicts.

Comments

9

Were those dev-masters added automatically? Avoid them as unnecessary version constraints, for 'any suitable version' use "*", or "@dev" if you don't mind dev packages. My guess is that Entrust is the potential troublemaker.

Also, "minimum-stability": "stable" imposes additional constraints, and

"minimum-stability": "dev", "prefer-stable": true 

is more conflict-free, consider it a rule of thumb.

2 Comments

The problem is the usage of unstable dev versions. Blindly allowing them (even if preferring stable) is the key to an unmaintainable mess.
@Sven The answer addresses the problem directly, which is dev-master constraint. It doesn't state that loose version constraints are good - they will probably result in a mess, and this is on developer's conscience. The fact that the answer isn't opinionated about tagging doesn't make it wrong. I Thanks for a downvote, by the way. That's quite ethical to downvote neighbouring answers.
7

I solved the same issue setting 'laravel/framework' dependency version from "^8.0" to "^7.0".

After that running composer update --ignore-platform-reqs simply worked

composer.json

2 Comments

As of today, the latest Laravel framework version is 7.10. So how did your dependency went up to 8.0?
not sure honestly since I’m pretty new with Laravel. It was a brand new installation with messing with the composer.json file
7

I am facing the same issue in Laravel v8.49.0 (PHP v8.0.6). Using Composer through install packages
I recently resolved the same issue by installing two packages:- composer create-project laravel/laravel myapp

your requirement could not be resolved

Composer Update

composer update --ignore-platform-reqs

OR
composer install --ignore-platform-reqs

Check Start Server
php artisan serve

enter image description here

2 Comments

server started and get "No Application Encryption Key Has Been Specified" check this stackoverflow.com/a/68219720/12635334
Prefer text, not images for accessibility and many other reasons.
4

This solution has been tested on Windows OS

  • Verify that PHP c:/php/bin/ exist in the environment path variable or drive:/path/php/bin/ and type php --version in terminal, command prompt or Windows PowerShell to make sure output matches to the following one. enter image description here Download PHP

  • Verify that Composer is installed by typing composer in the terminal, command prompt, or Windows PowerShell matches the following output. enter image description here Download Composer

  • Make sure to type the correct command for initializing the Laravel project: composer create-project laravel/laravel ProjectName Click here to read official docs.


If you're still getting errors, just follow the solution for Laravel:

  1. Just open the file c:/php/php.ini in any text editor

  2. Find the ;extension=fileinfo statement

  3. Uncomment it, remove semi-colon (;) from the start, just make it extension=fileinfo

  4. Save the file

Comments

3

Install the following according to the PHP version installed on your system:

sudo apt-get install php8.0-curl php8.0-gd php8.0-xsl php8.0-dom 

Finally try again to create the laravel project with composer

composer create-project laravel/laravel myProject 

Comments

3

You must be in the correct directory so cd into it, then: composer update --ignore-platform-reqs if you have previous installed composer as Vivek M suggests. My problem was wrong directory. cd into: xampp/htdocs/laravelProjects/laravelP1

Comments

2

I also meet this when trying to create laravel project, try this and it may works for you as well

Change from

;extension=fileinfo 

to

extension=fileinfo 

Comments

1

Add "barryvdh/laravel-cors": "^0.7.3" at the end of require array inside composer.json

Save composer.json and run composer update

You are done !

1 Comment

People should never use composer update to install dependencies. It should use composer install. Composer update will update all dependencies and that could be catastrophic.
1

I solved the same error, by adding "zizaco/entrust": "*" instead of the "zizaco/entrust": "~1.2".

Comments

0

I encountered this problem in Laravel 5.8, what I did was to do composer require for each library and all where installed correctly.

Like so:

instead of adding it to the composer.json file or specifying a version:

composer require msurguy/honeypot: dev-master 

I instead did without specifying any version:

composer require msurguy/honeypot 

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.