Common Composer errors and their solutions

藏色散人
Release: 2020-10-13 10:37:55
forward
4545 people have browsed it

The following tutorial column of composer will introduce you to common Composer errors and their solutions. I hope it will be helpful to friends in need!

Common Composer errors and their solutions

Composer common error solutions

Encountered an error when executing composer install: Your requirements could not be resolved to an installable set of packages. This is because the version required by composer.json does not match.

The complete error is as follows:

vagrant@homestead:/usr/share/nginx/html/laravel-blog$ sudocomposerinstall
Loadingcomposerrepositorieswithpackage information
Installingdependencies (includingrequire-dev) fromlockfile
Yourrequirementscouldnot beresolvedto aninstallablesetofpackages.
  
  Problem 1
    - Installationrequestfor doctrine/instantiator 1.0.3 -> satisfiablebydoctrine/instantiator[1.0.3].
    - doctrine/instantiator 1.0.3 requiresphp ~5.3 -> yourPHPversion (7.0.3) doesnot satisfythatrequirement.
  Problem 2
    - doctrine/instantiator 1.0.3 requiresphp ~5.3 -> yourPHPversion (7.0.3) doesnot satisfythatrequirement.
    - phpunit/phpunit-mock-objects 2.3.0 requiresdoctrine/instantiator ~1.0,>=1.0.1 -> satisfiablebydoctrine/instantiator[1.0.3].
    - Installationrequestfor phpunit/phpunit-mock-objects 2.3.0 -> satisfiablebyphpunit/phpunit-mock-objects[2.3.0].
Copy after login

It prompts that my PHP 7 version is too high and does not meet the version required by composer.json. However, it should also be able to run under PHP 7. Composer can be set to ignore it. The versions match. The command is:

composerinstall --ignore-platform-reqs
Copy after login

or

composerupdate --ignore-platform-reqs
Copy after login

. Execute the composer command again to install the package normally.

If a warning is prompted:

Cannotcreatecachedirectory /home/vagrant/.composer/cache/repo/https---packagist.org/, or directoryis not writable. Proceedingwithoutcache
  Cannotcreatecachedirectory /home/vagrant/.composer/cache/files/, or directoryis not writable. Proceedingwithoutcache
Copy after login

This is when composer is executed in a virtual machine, prompting that this directory does not have writable permissions. Composer cannot cache the downloaded package, so it must be downloaded again every time. Just change the directory to be writable and readable.

sudo chmod -R 777 /home/vagrant/.composer/cache/files/
Copy after login

In addition, set composer as the domestic image in the virtual machine, otherwise the download speed will be extremely slow. Execute:

composerconfig -g repo.packagistcomposerhttps://packagist.phpcomposer.com
Copy after login

The above is the detailed content of Common Composer errors and their solutions. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:cnblogs.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template