Get the App
SLTechnology News&Howtos  ›  Internet Technology  › 

What are the common mistakes in Composer

Shulou Source: shulou.com Published: 2022-06-02 16:41:08 10月05日 Update

This article mainly introduces what are the common mistakes in Composer, which can be used for reference. I hope you can learn a lot after reading this article.

Error encountered in 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$ sudocomposerinstallLoadingcomposerrepositorieswithpackage informationInstallingdependencies (includingrequire-dev) fromlockfileYourrequirementscouldnot 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 is suggested that my version of PHP 7 is too high to meet the required version of composer.json, but it should also run under PHP 7. Composer can be set to ignore version matching. The command is:

Composerinstall-ignore-platform-reqsorcomposerupdate-ignore-platform-reqs

Execute the composer command again to install the package normally.

If prompted to warn:

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 to execute composer in the virtual machine, indicating that there is no writeable permission for this directory, and composer cannot cache the downloaded package, so you have to download it again every time and change the directory to 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, and execute:

Composerconfig-g repo.packagistcomposer https://packagist.phpcomposer.com

OK, it's done.

Thank you for reading this article carefully. I hope the article "what are the common mistakes in Composer" shared by the editor will be helpful to you. At the same time, I also hope that you will support us and pay attention to the industry information channel. More related knowledge is waiting for you to learn!

Tags: Errors versions articles tips common commands are in the directory done value interest again at the same time great merit more friends permissions knowledge cache tape Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno macOS vpn MariaDB Xiaomi Linux