▪ 前言
以前一直觉得 Composer 很可怕,动不动就报错,的确表面上看很可怕。
但其实,只要仔细分析它给出的错误提示,按图索骥,是可以解决问题的。
那今天我就记录下我 Composer 安装 yiisoft/yii2-apidoc 2.1.0 时解决错误的过程。
▪ 准备
首先,我安装 yii2-apidoc 的时候,很慢,于是百度了一下,嗯,这个需要切换成中国镜像就快了,参 Composer中文网,配置镜像的命令:
$ composer config -g repo.packagist composer https://packagist.phpcomposer.com
▪ 安装
进入开发网站的根目录,执行以下命令:
$ composer require yiisoft/yii2-apidoc 2.1.0 -vvv
参数 -vvv 表示输出更多信息,相当于 Debug 状态
1. 上述命令执行可能出现以下错误
Your requirements could not be resolved to an installable set of packages.
Problem 1
- Can only install one of: phpdocumentor/reflection-docblock[2.0.4, 3.1.1].
- Can only install one of: phpdocumentor/reflection-docblock[3.1.1, 2.0.4].
- Can only install one of: phpdocumentor/reflection-docblock[2.0.4, 3.1.1].
- yiisoft/yii2-apidoc 2.1.0 requires phpdocumentor/reflection-docblock ^2.0. 4 -> satisfiable by phpdocumentor/reflection-docblock[2.0.4].
- Installation request for yiisoft/yii2-apidoc 2.1.0 -> satisfiable by yiiso ft/yii2-apidoc[2.1.0].
- Installation request for phpdocumentor/reflection-docblock (locked at 3.1. 1) -> satisfiable by phpdocumentor/reflection-docblock[3.1.1].
Installation failed, reverting ./composer.json to its original content.
通过上面的反馈信息,可以分析缺少 reflection-docblock
,那么直接就先安装它:
$ composer require phpdocumentor/reflection-docblock 2.0.4 -vvv
再执行 apidoc 安装命令:
$ composer require yiisoft/yii2-apidoc 2.1.0 -vvv
2. 上述命令执行可能出现以下错误:
Problem 1
- Installation request for yiisoft/yii2-apidoc 2.1.0 -> satisfiable by yiiso ft/yii2-apidoc[2.1.0].
- Conclusion: remove cebe/markdown 1.1.1 - Conclusion: don't install cebe/markdown 1.1.1 - yiisoft/yii2-apidoc 2.1.0 requires cebe/markdown-latex ~1.0 -> satisfiable by cebe/markdown-latex[1.0.0, 1.1.0, 1.1.1, 1.1.2, 1.1.3].
- cebe/markdown-latex 1.0.0 requires cebe/markdown ~1.0.0 -> satisfiable by cebe/markdown[1.0.0, 1.0.1, 1.0.2].
- cebe/markdown-latex 1.1.0 requires cebe/markdown ~1.0.0 -> satisfiable by cebe/markdown[1.0.0, 1.0.1, 1.0.2]. - cebe/markdown-latex 1.1.1 requires cebe/markdown ~1.0.0 -> satisfiable by cebe/markdown[1.0.0, 1.0.1, 1.0.2].
- cebe/markdown-latex 1.1.2 requires cebe/markdown ~1.0.0 -> satisfiable by cebe/markdown[1.0.0, 1.0.1, 1.0.2].
- cebe/markdown-latex 1.1.3 requires cebe/markdown ~1.0.0 -> satisfiable by cebe/markdown[1.0.0, 1.0.1, 1.0.2]. - Can only install one of: cebe/markdown[1.0.0, 1.1.1].
- Can only install one of: cebe/markdown[1.0.1, 1.1.1].
- Can only install one of: cebe/markdown[1.0.2, 1.1.1].
- Installation request for cebe/markdown (locked at 1.1.1) -> satisfiable by cebe/markdown[1.1.1].
Installation failed, reverting ./composer.json to its original content.
通过上面的反馈信息,可以分析缺少 reflection-docblock
,那么直接就先安装它:
$ composer require cebe/markdown 1.0.0 -vvv
再执行 apidoc 安装命令:
$ composer require yiisoft/yii2-apidoc 2.1.0 -vvv
▪ 成功
出现以下反馈信息或类似信息后,那么就表明安装成功了。
REASON: Required by the root package: Install command rule (install yiisoft/ yii2-apidoc 2.1.0)
Reading d:\www\testcomposer/vendor/composer/installed.json
Writing lock file
Generating autoload files