Home >Development Tools >composer >Common Composer errors and their solutions
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!
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].
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
. 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
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/
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
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!