composer third-party packages import process, the emergence Your requirements could not be resolved to an installable set of packages how to deal with?

1. Create composer.json files in the specified folder and fill in the relevant configuration code

Here is an example of style: requirethe introduction 包名: endroid/qr-code| 版本号: 2.5.1
Note: All documents are quoted 双引号, and json format can not be wrong

{
	"require": {
	    "endroid/qr-code": "2.5.1"
	    //定义依赖版本的格式  1.* 代表:1.几的版本  ^ 2.0.3代表:2.0.3以上版本  
	    "vendor/package": "1.3.2",
        "vendor/package2": "1.*",
        "vendor/package3": "^2.0.3"
	}
}
2, execute commands have composer.json file folder: composer install

Note: If Your requirements could not be resolved to an installable set of packages.the code is not caused by the release of the first to 检查版本格式whether to write correctly. Another is that php版本there is a problem.

Here Insert Picture Description
Successful installation will appear two new content vendorand composershown:

vendor: Is dependent on the contents of the package file and all dependent packages are downloaded into this file
composer.lock: lock version, which contains the version number and address to download and there are other dependencies of the current package Download

Here Insert Picture Description

3. The introduction of documentation vendor/autoload.phpfile (an example two-dimensional code)
//载入文件
include_once "./vendor/autoload.php";
//使用插件
use Endroid\QrCode\QrCode;
//定义二维码信息
$qrCode = new QrCode('https://www.baidu.com');

header('Content-Type: '.$qrCode->getContentType());
echo $qrCode->writeString();
4. The results are shown in document application

Here Insert Picture Description

Published 156 original articles · won praise 531 · views 110 000 +

Guess you like

Origin blog.csdn.net/qq_39043923/article/details/99736495