Composer settings ignore version matching method, composer matching_PHP tutorial

WBOY
Release: 2016-07-12 08:53:30
Original
864 people have browsed it

Composer sets the method to ignore version matching, composer matching

Composer introduction

Composer is a dependency management tool for PHP. It allows you to declare code libraries that your project depends on and it will install them for you in your project. Composer is not a package manager. Yes, it involves "packages" and "libraries", but it's managed on a per-project basis, with installations in some directory within your project (e.g. vendor). By default it won't install anything globally. So this is just a dependency management.

Executing composer install encountered an error: 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$ sudo composer install
Loading composer repositories with package information
Installing dependencies (including require-dev) from lock file
Your requirements could not be resolved to an installable set of packages.
Problem 1
- Installation request for doctrine/instantiator 1.0.3 -> satisfiable by doctrine/instantiator[1.0.3].
- doctrine/instantiator 1.0.3 requires php ~5.3 -> your PHP version (7.0.3) does not satisfy that requirement.
Problem 2
- doctrine/instantiator 1.0.3 requires php ~5.3 -> your PHP version (7.0.3) does not satisfy that requirement.
- phpunit/phpunit-mock-objects 2.3.0 requires doctrine/instantiator ~1.0,>=1.0.1 -> satisfiable by doctrine/instantiator[1.0.3].
- Installation request for phpunit/phpunit-mock-objects 2.3.0 -> satisfiable by phpunit/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, but it should be able to run under PHP 7. Composer can be set to ignore version matching. The command is:

composer install --ignore-platform-reqs
Copy after login

or

composer update --ignore-platform-reqs
Copy after login

Execute the composer command again to install the package normally.

If a warning is prompted:

Cannot create cache directory /home/vagrant/.composer/cache/repo/https---packagist.org/, or directory is not writable. Proceeding without cache
Cannot create cache directory /home/vagrant/.composer/cache/files/, or directory is not writable. Proceeding without cache
Copy after login

This is when composer is executed in a virtual machine. It prompts that this directory does not have writable permissions. Composer cannot cache the downloaded package, so it has to 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:

composer config -g repo.packagist composer https://packagist.phpcomposer.com
Copy after login

OK, you’re done.

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/1123827.htmlTechArticleComposer settings ignore version matching method, composer matching Composer introduction Composer is a dependency management tool for PHP. It allows you to declare the code base your project depends on, and it will be in your...
Related labels:
source:php.cn
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