Home > Development Tools > composer > Introduction to solutions to common Composer errors

Introduction to solutions to common Composer errors

藏色散人
Release: 2020-01-08 14:33:29
forward
3002 people have browsed it

Below, composer uses the tutorial column to introduce solutions to common Composer errors. I hope it will be helpful to friends in need!

Introduction to solutions to common Composer errors

I 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
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

OK, and you're done.

For more composer-related technical articles, please visit the composer column: //m.sbmmt.com/tool/composer/

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

Related labels:
source:csdn.net
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