使用TP5.0框架的验证码时需要先安装验证码类,但是在安装中遇到了各种各样的问题,搞了半天终于安装成功了,下面将问题汇总一下,
首先要安装composer,大部分“composer require topthink/think-captcha
”命令无法运行或者提示不是内部文件或可执行命令,都是因为没有安装composer,或安装不成功。直接百度搜composer即可,有链接,百度经验里也有教程,不在这里详细介绍了。
composer安装成功后,在你的项目主目录地址栏里输入cmd,然后输入composer require topthink/think-captcha
来下载安装captcha,当然此时有很大概率会报错,
来说一下我遇到的两个问题吧,
第一:网络问题,输入“”composer require topthink/think-captcha
“”窗口一直无响应,此时需要使用以下命令修改composer配置文件,使用国内镜像。原因你懂的。
composer config -g repo.packagist composer https://packagist.phpcomposer.com
第二:版本问题:此时有大概率会引版本不符而报错,错误提示代码如下:
Your requirements could not be resolved to an installable set of packages.
Problem 1
- topthink/think-captcha v2.0.1 requires topthink/framework 5.1.x-dev -> satisfiable by topthink/framework[5.1.x-dev] but these conflict with your requirements or minimum-stability.
- topthink/think-captcha v2.0 requires topthink/framework 5.1.x-dev -> satisfiable by topthink/framework[5.1.x-dev] but these conflict with your requirements or minimum-stability.
- Installation request for topthink/think-captcha ^2.0 -> satisfiable by topthink/think-captcha[v2.0, v2.0.1, v2.0.2].
- Conclusion: don\'t install topthink/framework v5.1.35
- Conclusion: don\'t install topthink/framework v5.1.34
- Conclusion: don\'t install topthink/framework v5.1.33
- Conclusion: don\'t install topthink/framework v5.1.32
- Conclusion: don\'t install topthink/framework v5.1.31
- Conclusion: don\'t install topthink/framework v5.1.30
- Conclusion: don\'t install topthink/framework v5.1.29
- Conclusion: don\'t install topthink/framework v5.1.28
- Conclusion: don\'t install topthink/framework v5.1.27
- Conclusion: don\'t install topthink/framework v5.1.26
- Conclusion: don\'t install topthink/framework v5.1.25
- Conclusion: don\'t install topthink/framework v5.1.24
- Conclusion: don\'t install topthink/framework v5.1.23
- Conclusion: don\'t install topthink/framework v5.1.22
- Conclusion: don\'t install topthink/framework v5.1.21
- Conclusion: don\'t install topthink/framework v5.1.20
- Conclusion: don\'t install topthink/framework v5.1.19
- Conclusion: don\'t install topthink/framework v5.1.18
- Conclusion: don\'t install topthink/framework v5.1.17
- Conclusion: don\'t install topthink/framework v5.1.16
- Conclusion: don\'t install topthink/framework v5.1.15
- Conclusion: don\'t install topthink/framework v5.1.14
- Conclusion: don\'t install topthink/framework v5.1.13
- Conclusion: don\'t install topthink/framework v5.1.12
- Conclusion: don\'t install topthink/framework v5.1.11
- Conclusion: don\'t install topthink/framework v5.1.10
- Conclusion: don\'t install topthink/framework v5.1.9
- Conclusion: don\'t install topthink/framework v5.1.8
- Conclusion: don\'t install topthink/framework v5.1.7
- Conclusion: don\'t install topthink/framework v5.1.6
- Conclusion: don\'t install topthink/framework v5.1.5
- Conclusion: don\'t install topthink/framework v5.1.4
- Conclusion: don\'t install topthink/framework v5.1.3
- Conclusion: don\'t install topthink/framework v5.1.2
- Can only install one of: topthink/framework[v5.1.0, v5.0.3].
- Can only install one of: topthink/framework[v5.1.0, v5.0.3].
- topthink/think-captcha v2.0.2 requires topthink/framework 5.1.* -> satisfiable by topthink/framework[v5.1.0, v5.1.1, v5.1.10, v5.1.11, v5.1.12, v5.1.13, v5.1.14, v5.1.15, v5.1.16, v5.1.17, v5.1.18, v5.1.19, v5.1.2, v5.1.20, v5.1.21, v5.1.22, v5.1.23, v5.1.24, v5.1.25, v5.1.26, v5.1.27, v5.1.28, v5.1.29, v5.1.3, v5.1.30, v5.1.31, v5.1.32, v5.1.33, v5.1.34, v5.1.35, v5.1.4, v5.1.5, v5.1.6, v5.1.7, v5.1.8, v5.1.9].
- Conclusion: don\'t install topthink/framework v5.1.1
- Installation request for topthink/framework (locked at v5.0.3, required as ^5.0) -> satisfiable by topthink/framework[v5.0.3].
Installation failed, reverting ./composer.json to its original content.
此时我们需要同步一下各自版本,建议使用命令:composer update --ignore-platform-reqs
执行成功之后,就可以使用命令:composer require topthink/think-captcha
来安装验证码类了